dataType: “json” won't work

前端 未结 7 1457
面向向阳花
面向向阳花 2020-12-10 16:19

I\'m trying to send back multiple variables from a php file to ajax using json in an array. The code in the php file works perfectly and does everything with my database lik

7条回答
  •  情话喂你
    2020-12-10 17:07

    It's easy to forget about an echo or a var_dump() that you may have been using in the past to test how your script is working.

    In my own script I had a var_dump(), which I had forgotten about, that wasn't using JSON_encode-ed text and sent plain text to the browser. This broke the dataType:"json" requirement and caused the success function not to work.

    Took me a while to find the problem as I had ctrl+f(ed) for echo only and forgot about the vagabond var_dump().

    printf is probably another suspect.

提交回复
热议问题