异步 Ajax格式:1
$.ajax({
url:url,
type:"GET",
data:data,
success:function(data){
//alert(data);
var result=$(data).find("result").text();
if(parseInt(result)==0){
var dia = $(data).find("dia").text();
var con = $(data).find("com").text();
var dtime = $(data).find("dtime").text();
$("div#dloginfo div#content").html(con);
$("div#dloginfo div div#time").html("时间:"+dtime);
}
},
error:function(data){
alert("操作失败!!");
}
});
$.ajax({
type: "POST",
url: "/ajax_do_something.php",
data: "items=" + selectedItems.join('|'),或者//data: "{username:'" + username + "',pwd:'" + pwd + "'}",
dataType: "text",
success: function (request) {
document.location.reload();
},
error: function(request,error){
alert('Error deleting item(s), try again later.');
}
}
);[/b]
2:
function select_goods_table(strockId){
$.post("${pageContext.request.contextPath}/stockcontrol/stockTable_selectStockProduct.action",{"rid":strockId},function(data){
eval("var mydata="+data);
$("#physical_inventory_list").children().remove();
var str="";
var rids="";
$.each(mydata,function(i,item){
rids+=item.RID;
str="<tr target='"+i+"' rel='"+item.RID+"' attr=\"{'RID':'"+item.RID+"', 'PRODUCT_NO':'"+item.PRODUCT_NO+"', 'PRODUCT_NAME':'"+item.PRODUCT_NAME+"', 'COMPANY':'"+item.COMPANY+"','SPECIFICATIONS':'"+item.SPECIFICATIONS+"','STOCK_NUMBER':'"+item.STOCK_NUMBER+"'}\" οndblclick='add_physical_stocklist(this);'>"+
"<td width='91'>"+item.PRODUCT_NO+"</td>"+
"<td width='91'>"+item.PRODUCT_NAME+"</td>"+
"<td width='28'>"+item.COMPANY+"</td>"+
"<td width='64'>"+item.SPECIFICATIONS+"</td>"+
"<td width='64'>"+item.STOCK_NUMBER+"</td>"+
"</tr>";
$(str).appendTo($("#physical_inventory_list"));
//$("#physical_inventory_list").append(str).initUI();
});
});
}