jQuery AJAX - Unexpected token + parsererror

后端 未结 6 1979
被撕碎了的回忆
被撕碎了的回忆 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:31

    It could be an issue with missmatching PHP associative/numeric arrays and Javascript objects.

    Try this:

    $data = new Array();
    $data['test'][] = "Row 1";
    $data['test'][] = "Row 2";
    echo json_encode($json, JSON_FORCE_OBJECT);
    

    This should force json encoder to always encode to objects instead of numeric arrays and may solve the problem.

提交回复
热议问题