Creating JSON data using PHP and parsing it using jQuery

前端 未结 3 467
醉梦人生
醉梦人生 2020-12-21 12:45

I am using a PHP script to create JSON data. It looks like this:

{\"Id\":0}

Now if I put that into a file and then load it using ajax it\'s

3条回答
  •  不思量自难忘°
    2020-12-21 13:13

    In your error function use this and check what data is being returned from the server.

    error: function(jqXHR, textStatus, errorThrown) {
       $('#result').html(textStatus + ' | ' + errorThrown + ' | ' + jqXHR.responseText);
       alert(jqXHR.responseText);
    }
    

    You will know where exactly it is going wrong. The data type and the special characters. Set the content type to application/json and encode your json string using json_encode(). Also, you don't need the doctypes.

提交回复
热议问题