An example of code with a return value in an ajax request.

Source: Internet
Author: User

An example of code with a return value in an ajax request.

Code example with ajax request and return value:

Jquery ajax is widely used to implement some refreshing requests. This section provides a very simple code example for your reference, the Code is as follows:

<Script type = "text/javascript">/* request Ajax with the returned value, and a prompt box pops up to remind ------------------------------------------ */function getAjax (url, parm, callBack) {$. ajax ({type: 'post', dataType: "text", url: url, data: parm, cache: false, async: false, success: function (msg) {callBack (msg) ;}}/* Delete/* url: indicates the Request Path ---------------------------------------------------- */function DeleteData (url, id) {var parm = 'Active = Del & Id = '+ id; if (id = undefined | id = "") {showAlertMsg ('select the row to delete ');} else {showConfirmMsg ("this operation cannot be recovered. Are you sure you want to delete it? ", Function (r) {if (r) {getAjax (url, parm, function (rs) {if (parseInt (rs)> 0) {showOverAlertMsg (" deleted successfully! ",);} Else if (parseInt (rs) = 0) {showOverAlertMsg (" this data is associated and cannot be deleted! ",);} Else {showOverAlertMsg (" deletion failed! ", 2000, 5) ;}}}) }}// delete function DeleteOnclick () {DeleteData ('sysmenu _ List. aspx ', Menu_Id) ;}</script>

Original address: http://www.51texiao.cn/jqueryjiaocheng/2015/0613/4216.html

The most original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 8649.

Related Article

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.