Home > Article > Backend Development > The result obtained from the data requested by PHP ajax is in Html format, which is the html of the current page. It cannot be converted into json. Please crack it.
This is the code. The format of dataType must be changed to html to obtain the data, otherwise an error 200 will be reported. $.ajax({
<code> type:"POST", async:false, url:"<?php echo $this->generateURL('Film.Index', array('save'));?>", data:dataparam, dataType:"json", success:function(msg){</code>
This is the code. The format of dataType must be changed to html to obtain the data, otherwise an error 200 will be reported. $.ajax({
<code> type:"POST", async:false, url:"<?php echo $this->generateURL('Film.Index', array('save'));?>", data:dataparam, dataType:"json", success:function(msg){</code>
Set the header on the server side, there must be no output before the header
<code>header('Content-type: application/json');</code>
Data assembled on the server side
<code>echo json_encode($var);</code>
This is caused by your server not returning the JSON format you expected. Please print the server output and see.
That is because the data returned by the server is not in json format, and it is not a front-end problem.