Ajax-return value-the demo of php returning json data is as follows. what causes this problem?

Source: Internet
Author: User
{Code...} php returns json data. if {code...} is contained in this line of code ajax, an error is returned. If this line of code is removed, the ajax result is success. the returned data is printed, and the annotated array is printed. I don't need ajax to request the server...

  query("select id from user2 where name = 'admin' and password ='admin'");//$user_details = $db->get_row(null, OBJECT, 0);//var_dump($user_details) ;$sql = sprintf("select * from user2 where name='%s' and password='%s'",$username,$password);//echo $sql;//select * from user2 where name='admin' and password='admin'$user=$db->get_results($sql);//var_dump($user);//array(1) { [0]=> object(stdClass)#5 (3) { ["id"]=> string(1) "1" ["name"]=> string(5) "admin" ["password"]=> string(5) "admin" } }if($user){  $result='0';   }else{   $result='-1';  }$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);echo json_encode($arr);?>

Php returns json data, if it contains


This line of code ajax returns error.

If this line of code is removed, the ajax result is success.
This line of code is okay. I printed the returned data, and the annotated array is printed out. if I don't need ajax to request the server code, I tested the code when submitting the form directly.

The html code is as follows:

          British I2Active        

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.