skip to Main Content

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.

enter image description here

But, while I use the same code in Edge, it triggers correctly.

enter image description here

Don’t know how to resolve it in Chrome? I’ve tried to clear the Cache. Also the same result.

2

Answers


  1. Chosen as BEST ANSWER

    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 the POST method in both Chrome and Edge browsers.

    So, now I'm using http://localhost:8000/.


  2. The 405 Method Not Allowed and Request Method: GET are a clear sign that the chrome browser use the default method GET.

    You can try method: 'POST' instead of type: '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

    ‘type’ is an alias for ‘method’. You should use ‘type’ if you’re using versions of
    jQuery prior to 1.9.0.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search