jQuery $.ajax(), $.post sending “OPTIONS” as REQUEST_METHOD in Firefox

前端 未结 23 2860
傲寒
傲寒 2020-11-22 14:38

Having trouble with what I thought was a relatively simple jQuery plugin...

The plugin should fetch data from a php script via ajax to add options to a

23条回答
  •  温柔的废话
    2020-11-22 15:16

    Please be advised:

    JSONP supports only the GET request method.

    *Send request by firefox:*

    $.ajax({
       type: 'POST',//<<===
       contentType: 'application/json',
       url: url,
       dataType: "json"//<<=============
        ...
    });
    

    Above request send by OPTIONS(while ==>type: 'POST')!!!!

    $.ajax({
        type: 'POST',//<<===
        contentType: 'application/json',
        url: url,
        dataType: "jsonp"//<<==============
        ...
    });
    

    But above request send by GET(while ==>type: 'POST')!!!!

    When you are in "cross-domain communication" , pay attention and be careful.

提交回复
热议问题