ajax調用實例
阿新 • • 發佈:2017-09-30
path digital lsd 訂閱 生活 mes erro iss count
海爾訂閱按鈕的例子:
$(".dingyue").click(function () { if (istrsidssdssotoken()) {//cookie 中的是否登錄 if (null == proid || "undefined" == proid) { return; } if (null == urlxmlpath || "undefined" == urlxmlpath) { return; } var productcate = ""; if (urlxmlpath.indexOf("/cooling/") > -1) { productcate = "冰箱"; } else if (urlxmlpath.indexOf("/laundry/") > -1) { productcate = "洗衣機"; } else if (urlxmlpath.indexOf("/air_conditioners/") > -1) { productcate = "空調"; } else if (urlxmlpath.indexOf("/televisions/") > -1) { productcate = "彩電"; } else if (urlxmlpath.indexOf("/kitchen_appliances/") > -1) { productcate = "廚房電器"; } else if (urlxmlpath.indexOf("/kitchen/") > -1) { productcate = "整體廚房"; } else if (urlxmlpath.indexOf("/water_heater/") > -1) { productcate = "熱水器"; } else if (urlxmlpath.indexOf("/small_applications/") > -1) { productcate = "生活小家電"; } else if (urlxmlpath.indexOf("/computers/") > -1) { productcate = "電腦"; } else if (urlxmlpath.indexOf("/lsdn/") > -1) { productcate = "歷史電腦"; } else if (urlxmlpath.indexOf("/digital/") > -1) { productcate = "手機數碼"; } var countryname = "cn"; jQuery.ajax({ type: "post", dataType: "json", url: "/HaierFramework/haier/mycollection/addProductCollectionAsync.do", data: { ‘productId‘: proid, ‘productxmlpath‘: urlxmlpath, ‘countryname‘: countryname, ‘productcategory‘: productcate }, success: function (returnResult) { if (returnResult.isSuccess) { if (returnResult.stutas == 2) { $(".js_collect_head").html(""); $(".js_collect_head").html("您已經收藏過此產品"); var logintype = LoginType(); if (logintype == "haierCounts") { $("#js_collect_threelogin").hide(); var userinfo = getuserinfo(); if (userinfo != "") { if (userinfo.indexOf(",") != -1) { var infoArray = userinfo.split(","); var emailtemp = infoArray[0]; var teltemp = infoArray[1]; var emailArray = emailtemp.split("="); email = emailArray[1]; var telArray = teltemp.split("="); tel = telArray[1]; } else { if (userinfo.indexOf("email") != -1) { var emailArray = userinfo.split("="); email = emailArray[1]; } else if (userinfo.indexOf("tel") != -1) { var telArray = userinfo.split("="); tel = telArray[1]; } } } $("#js_message_mail2").val(email); $("#js_message_tel2").val(tel); } else { $("#js_collect_haierlogin").hide(); } $(".js_btn_collect").click(); } else { var logintype = LoginType(); if (logintype == "haierCounts") { $("#js_collect_threelogin").hide(); var userinfo = getuserinfo(); if (userinfo != "") { if (userinfo.indexOf(",") != -1) { var infoArray = userinfo.split(","); var emailtemp = infoArray[0]; var teltemp = infoArray[1]; var emailArray = emailtemp.split("="); email = emailArray[1]; var telArray = teltemp.split("="); tel = telArray[1]; } else { if (userinfo.indexOf("email") != -1) { var emailArray = userinfo.split("="); email = emailArray[1]; } else if (userinfo.indexOf("tel") != -1) { var telArray = userinfo.split("="); tel = telArray[1]; } } } $("#js_message_mail2").val(email); $("#js_message_tel2").val(tel); } else { $("#js_collect_haierlogin").hide(); } $(".js_btn_collect").click(); } //監控代碼 collection_success(); } else { gotoLogin(); } }, error: function () { } }); } else { gotoLogin(); } })
最簡單的例子:
$.ajax({ url:"/api/workflow/task!cancelAndAgreeOrDisagreeStep.do", dataType: ‘json‘, type: ‘post‘, data: { task_id: task_id }, success: function success(data) { //成功後執行的動作 }, error: function error() { //alert(‘獲取信息失敗‘); } });
只是記錄一下~
ajax調用實例