문제

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?

도움이 되었습니까?

해결책 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. ;)

다른 팁

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top