Thinkphp uses ajax to achieve level-2 interaction

Source: Internet
Author: User
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!

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.