The following code triggers a GET Method instead of POST.
$.ajax({type: 'POST',url: 'http://localhost:8000/DoAsync',data: {i:e},dataType: 'script'
});
It’s happened in Chrome.
But, while I use the same code in Edge, it triggers correctly.
Don’t know how to resolve it in Chrome? I’ve tried to clear the Cache. Also the same result.
2
Answers
When I use
http://127.0.0.1:8000/
to access the server, I've received the error in Chrome, but not in Edge.Whereas
http://localhost:8000/
to access the server, performs correctly thePOST
method in both Chrome and Edge browsers.So, now I'm using
http://localhost:8000/
.The
405 Method Not Allowed
andRequest Method: GET
are a clear sign that the chrome browser use the default method GET.You can try
method: 'POST'
instead oftype: 'POST'
as already mentioned by @aynber, but it would only solve the problem if you are using an old jQuery Version.See jQuery ajax documentation for more information