$. GetJSON cannot get the php output value

Source: Internet
Author: User
$. GetJSON cannot get the php output value. js code:
Start_btn.click (function (){
$. GetJSON ("data. php", function (json ){
If (json ){
Var len = json. length;
_ Gogo = setInterval (function (){
Var num = Math. floor (Math. random () * len );
Var id = json [num]. id;
Var v = json [num]. mobile;
$ ("# Roll" pai.html (v );
$ ("# Mid"). val (id );
},100 );
Stop_btn.show ();
Start_btn.hide ();
} Else {
$ ("# Roll" login .html ("The system cannot find resources. please import data first ");
}
});
});

Php code:
If ($ action = "") {// read data, return json
$ Query = mysqli_query ($ conn, "select * from member where status = 0 ");
While ($ row = mysqli_fetch_array ($ query )){
$ Arr [] = array (
'Id' => $ row ['id'],
'Mobile' => substr ($ row ['mobile'], 0, 3 ). "****". substr ($ row ['mobile'],-4, 4 ));
}
$ J_arr = json_encode ($ arr );
Echo $ j_arr;
}


Reply to discussion (solution)

1. run php directly to check whether the returned json is correct. if the returned json is correct, php is normal. otherwise, php has a problem.
2. if php is normal, print the json of js to see if there are any errors.

1. run php directly to check whether the returned json is correct. if the returned json is correct, php is normal. otherwise, php has a problem.
2. if php is normal, print the json of js to see if there are any errors.



How can I print out json? php is normal.

Echo bin2hex (file_get_contents ('http: // localhost/data. php '));

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.