jQuery AJAX Call to PHP Script with JSON Return

后端 未结 5 457
孤城傲影
孤城傲影 2020-11-27 04:40

I\'ve been smashing my head against a brick wall with this one, i\'ve tried loads of the solutions on stackoverflow but can\'t find one that works!

Basically when I

5条回答
  •  有刺的猬
    2020-11-27 04:58

    Make it dataType instead of datatype.

    And add below code in php as your ajax request is expecting json and will not accept anything, but json.

    header('Content-Type: application/json');
    

    Correct Content type for JSON and JSONP

    The response visible in firebug is text data. Check Content-Type of the response header to verify, if the response is json. It should be application/json for dataType:'json' and text/html for dataType:'html'.

提交回复
热议问题