jQuery AJAX - Unexpected token + parsererror

后端 未结 6 2053
被撕碎了的回忆
被撕碎了的回忆 2021-02-07 08:59

I wrote a script using jQuery and AJAX today, and I get some errors...

The script:

function changeAdmin(id) {
$(document).ready(function() {
    $(\'#ta         


        
6条回答
  •  耶瑟儿~
    2021-02-07 09:29

    You need to send an application/json header via PHP , like this:

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

    That's because jQuery sends an Accept header (application/json, text/javascript), and this is the cause of parseerror triggered by jqXHR.

提交回复
热议问题