jquery 之ajax,get,post异步请求简单代码模版

Posted 爱跳舞的程序员

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jquery 之ajax,get,post异步请求简单代码模版相关的知识,希望对你有一定的参考价值。

$.get(                        "../cart/cart_list.do",

                               "productId="+productId,

                               function(data){

                                   alert(data);

                               }

  );

post

$.post(  "../cart/cart_list.do",

                   "productId="+productId,

                     function(data){

                                   alert(data);

                               }

         );

 

Post与get的格式是一样的

Ajax

url=__ctx+"/maintenance/onceequipment/tdJxdEquipment/dialogGltxfsdSend.ht";

var params ={

                                                                                    "ids":arrIds,

                                                                                    "id":id

                                                                 };

$.ajax({

                 "url":url,

                 "type":"post",

            "async":true,

            "data":params,

            "dataType":"json",

            "success":function(data){

                      if(data==‘true‘){

                                             $.ligerDialog.success("操作成功","提示信息", function(rtn) {

                                                       if(rtn){

                                                                //刷新父类窗口

                                                                try{

                                                                getParentWindow().refreshLeftTree();

                                                                }catch(e){}

                                                                self.location=document.referrer;

                                                       }

                        });

                                    }else{

                                             $.ligerDialog.err("提示信息","失败!","操作失败");

                                             //刷新父类窗口

                                             try{

                                             getParentWindow().refreshLeftTree();

                                             }catch(e){}

                      self.location=document.referrer;

                                    }

             }

        });

以上是关于jquery 之ajax,get,post异步请求简单代码模版的主要内容,如果未能解决你的问题,请参考以下文章

python测试开发django-130.jQuery中$.ajax()方法发GET/POST/DELETE请求

理解jQuery中$.get$.post$.getJSON和$.ajax的用法

Ajax异步请求

Jquery的$.get(),$.post(),$.ajax(),$.getJSON()用法详细解读

JQuery $.ajax(); 异步访问完整参数

019-JQuery(Ajax异步请求)