Jquery ajax异步请求样板

    $.ajax({
        url : '<%=basePath%>industry/add', // 为请求的url
        data: "pid=" + pid + "&tradeName=" + name,
        type : "post", // post请求方式
        dataType : "json",
        success : function(msg) { // 其中msg是服务器上返回的数据,可以alert查看一下
            
            var str = "";
            $.each(msg, function(i, item) {
                str = str + "<option value='" + item.industryId + "'>" + item.tradeName + "</option>";
            });
            if(pid == 0){
                $("#PIndustry").val("");
                $("#PIndustryName").empty();
                $("#PIndustryName").append(str);
            }else{
                $("#Industry").val("");
                $("#IndustryName").empty();
                $("#IndustryName").append(str);
            }
        }
        
    });

 

$.ajax({
    type: 'get',
    url: '<%=basePath%>project/deleters/'+rid,
    data:{imgName:imgName},
    dataType: 'json',
    success: function(msg){
      alert( "图片删除");
      $('#'+itemId).remove();
    }
     });

 

posted on 2014-07-15 10:21  Ganymede505  阅读(265)  评论(0编辑  收藏  举报