分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

ajax调用实例

发布时间:2023-09-06 01:15责任编辑:苏小强关键词:暂无标签

海尔订阅按钮的例子:

 ???$(".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调用实例

原文地址:http://www.cnblogs.com/circleone/p/7614518.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved