Several types of Ajax commonly used by JQ and thinkphp

Source: Internet
Author: User

The first of these methods

The second method of

jquery method: Messageaction.class.php<?Phpclass Messageaction extends action{function index () {$this->display ();        } function Add () {//ajaxreturn (data, ' hint information ', state) $m =m (' message ');        if ($m->add ($_get)) {$this->ajaxreturn ($_get, ' Add information succeeded ', 1);           }else{$this->ajaxreturn (0, ' Add information failed ', 0); }}}?> template index.HtmlJavaScriptSrc= "__public__/js/jquery-1.7.1.min.js" ></script><script type= "Text/javascript" > $ (Function () {$ (            ' Input:button '). Click (function () {var $title =$ (' input[name= "title"] '). Val ();            var $message =$ (' input[name= ' "message"]). Val ();           $mess =$ (' #mess ');                $.getjson (' __url__/add ', {title: $title, Message: $message},function (JSON) {//alert (JSON); return false; if (JSON.status==1) {$mess. Slidedown (3000,function () {$mess. css (' Display ', ' block ');                   }). html (' title ' +json.data.title+ ' information for ' +json.data.message '); }else{$mess. Slidedown (3000,function () {$mess.CSS (' Display ', 'Block '); }). html (' information added failed, please check '); } }); })}) </script></Head><body><divStyle= "Display:none; color:red; "id=" mess "></div><form action=" "method=" Get "> title: <input type=" text "name=" title "/> <br/> Info: <input type= "text" name= "message"/><br/> <input type= "button" value= "Commit"/></form ></body>Phpclass Messageaction extends action{function index () {$this->display ()} function Addtwo () {$m =m (' message '); if ($v o= $m->create ()) {if ($m->add ()) {$this->ajaxreturn ($vo, ' Add succeeded ', 1);} else{$this->ajaxreturn (0, ' Add failed ', 0);}} else{$this->error ($m->geterror ());}} }?> Template index.html<html>JavaScript" src= "__public__/js/base.js" > </script><script type= "Text/javascript" src= "__public__/js/prototype.js" ></script><script Type= "Text/javascript" src= "__public__/js/mootools.js" ></script><script type= "Text/javascript" src= "_ _public__/js/thinkajax.js "></script><script type=" Text/javascript "> Function Add () {// Thinkajax.sendform (Form Id,url, callback function, where information is displayed); Thinkajax.sendform (' frm ', ' __url__/addtwo ', WC); } function WC (data,status) {if (status!=1) {alert (' send failed ');} else{$ (' list '). innerhtml+= ' title ' +data.title+ ', Information ' +data.message;}} </script></head><body>      

Several types of Ajax commonly used by JQ and thinkphp

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.