PHP Ajax request to the data obtained by the result of the HTML format, is the current page of HTML, conversion is not JSON, seek to crack

Source: Internet
Author: User
This is the code, you must change the format of datatype to HTML to get the data, or error 200 will be error. $.ajax ({

                                type:"POST",                                async:false,                                url:"
  
   generateURL('Film.Index', array('save'));?>",                                data:dataparam,                                dataType:"json",                                success:function(msg){

Reply content:

This is the code, you must change the format of datatype to HTML to get the data, or error 200 will be error. $.ajax ({

                                type:"POST",                                async:false,                                url:"
  
   generateURL('Film.Index', array('save'));?>",                                data:dataparam,                                dataType:"json",                                success:function(msg){

Set header on server, no output before header

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

Data assembled on the service side

echo json_encode($var);

This is caused by your service side not returning your expected JSON format, you print out the service-side output to see.

That is the data returned by the server is not a JSON format, not a front-end issue.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.