Pergunta

Given this very simple HTML code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="Scripts/jquery-1.10.2.js"></script>
    </head>
    <body>
        <script>
            $.ajax({
                url: "/MyURL/",
                data: "TEST",
                type: "POST"
            });
        </script>
    </body>
</html>

I load this page with Fiddler observing.

The HTTP request is observed to be a GET rather than the requested POST. Why?

Foi útil?

Solução 2

So your local copy of jQuery 1.10.2 is modified in some way, maybe overwritting global ajax option to make all ajax requests using GET method. You should then update your jq local copy or use any CDN. ;)

Outras dicas

Edit: This was an illusion caused by a local custom version of jQuery 1.10.2


It seems that jQuery 1.10.2 suffers from this problem, but it is "Fixed" (assuming that it's a bug in the first place) in jQuery 1.11.0.

With luck this will prevent someone else from tearing their hair out :)

try this

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="Scripts/jquery-1.10.2.js"></script>
    </head>
    <body>
        <script>
        var variable="TEST";
            $.ajax({
                url: "test.php",
                data: ({test:variable}),
                type: "post"
            });
        </script>
    </body>
</html>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top