Thinkphp uses ajax to create a second-level public function Billing ()
{
// Backend ajax verification
$ Result = array ();
$ Cate ['s _ customer'] = $ _ POST ['s _ customer'];
$ Result = M ('customer')-> where ($ cate)-> field ('phone, c_name ')-> select ();
$ This-> ajaxReturn ($ result, "json ");
$ This-> display ();
}
Why are only arrays displayed, but my original webpage is not displayed? is there a problem with my output?
Only [{"phone": "13802149988", "c_name": "\ u5f20 \ u4e09" },{ "phone": "13802144455", "c_name ": "\ u674e \ u56db"}], F12 check, found that only this array on the page, nothing else ..
Script
$ ('# S_Customer'). change (function (){
$. Ajax ({
Url: "{: U ('crud/billing ')}",
Type: 'post ',
Data :{
Name: $ ('# S_Customer'). val ()
},
DataType: 'json ',
Success: function (data ){
If (data. success)
{Users ('{phone'}.html (data. msg )}
Else {alert ("failed ")}
},
Error: function (data) {alert (data. status );}
})
})
Script
How can we achieve Level-2 interaction ..
Reply to discussion (solution)
Please give me the answer !!..
$ This-> ajaxReturn contains an exit
$ This-> ajaxReturn contains an exit
Well, I am a beginner, so I still don't understand what you mean .. Thank you!
The ajax response of thinkphp returns json by default.
Besides, you will also notify $. ajax to return json decoding for me (dataType: 'json ',)
However, there are no success or msg items in your returned results.
In response ('your phone'your .html (data. msg), the content of data. msg should be html code.
Do not copy people's code at will. you need to understand why you need to write that code.
The ajax response of thinkphp returns json by default.
Besides, you will also notify $. ajax to return json decoding for me (dataType: 'json ',)
However, there are no success or msg items in your returned results.
In response ('your phone'your .html (data. msg), the content of data. msg should be html code.
Do not copy people's code at will. you need to understand why you need to write that code.
Thank you for your advice!