当前位置: 首页 > news >正文

怎么做淘宝链接网站长沙的科技公司

怎么做淘宝链接网站,长沙的科技公司,上海公司排名100强,温岭企业网站建设公司之前一直使用jQuery的ajax方法#xff0c;导致自己对浏览器原生的XMLHttpRequest对象不是很熟悉#xff0c;于是决定自己写下#xff0c;以下是个人写的deom#xff0c;发表一下#xff0c;聊表纪念。 Ajax 和 jsonp 的javascript 实现#xff1a; /*! * ajax.js * 导致自己对浏览器原生的XMLHttpRequest对象不是很熟悉于是决定自己写下以下是个人写的deom发表一下聊表纪念。 Ajax 和 jsonp 的javascript 实现 /*! * ajax.js * © auth zernmal * description XMLHttpRequest and Jsonp practice */function ajax(url,options ){var options options || {} ,method options.method || GET,async (typeof options.async ! undefined) ? options.async : true ,user (typeof options.user ! undefined) ? options.user : ,pswd (typeof options.pswd ! undefined) ? options.pswd : ,reciveType options.reciveType || string ,data options.data || null ,header options.header || [],callback options.callback || function(){},xhr XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject(Microsoft.XMLHTTP);if(methodGET data){var dataStr [];url (url.indexOf(?)-1) ? url ? : url ; for(var i in data){dataStr.push( i data[i]) ;}url dataStr.join();data null;}else if(data){var form new FormData(); for(var i in data){form.append( i , data[i]); }data form;}xhr.onreadystatechange function() {if (xhr.readyState 4) {// 4 loadedif (xhr.status 200) {// 200 OKvar responseData null ;if(reciveTypestring){responseData xhr.responseText;}else if(reciveType json){responseData xhr.responseText;if( false JSON JSON.parse) {responseData JSON.parse(responseData);}else{responseData eval((responseData));}}options.callback options.callback(responseData);} else {alert(Problem retrieving XML data);}}};xhr.open(method , url , async , user ,pswd); for(var i header.length -1 ; i 0 ; i--){xhr.setRequestHeader(header[i].type, header[i].content); }xhr.send(data); }function jsonp(url , options){var options options || {} ,script document.createElement(script) ,callback options.callback || function(result){} ,callbackName myjsonpcall (new Date()).getTime(),data options.data || {} ,dataStr [];for(var i in data){dataStr.push( i data[i]) ;}if(url.indexOf(?)-1){url ? dataStr.join() callbackcallbackName;}else{url dataStr.join() callbackcallbackName;}script.setAttribute(src, url); window[callbackName] callback ;// 把script标签加入head此时调用开始document.getElementsByTagName(head)[0].appendChild(script); } PHP服务端响应请求 ?php$func $_GET[func];if(function_exists($func)){$func();}else{funcNotExist();}function funcNotExist(){echo function is not exist ! ;}function returnJson(){$lastName $_GET[lastName];$firstName $_GET[firstName];echo json_encode(array(firstName$firstName,lastName$lastName));}function returnString(){$lastName $_GET[lastName];$firstName $_GET[firstName];echo the string you send is .$lastName. .$firstName;}function postReturn(){$lastName $_POST[lastName];$firstName $_POST[firstName];echo the string you post is .$lastName. .$firstName;}function jsonP(){header(content-type: application/json; charsetutf-8);$lastName $_GET[lastName];$firstName $_GET[firstName];$callbackFunc isset($_GET[callback])? htmlspecialchars($_GET[callback]):callback;$json json_encode(array(firstName$firstName,lastName$lastName));echo $callbackFunc($json);} 页面内调用方法 !DOCTYPE html html headmeta http-equivContent-Type contenttext/html; charsetutf-8 /titleAjax与Jsonp实践/titlescript typetext/javascript srcjs/ajax.js/script /head body scriptjsonp(/ajax.php?funcjsonP,{callback : function(result){console.log(result);},data : {lastName : zernmal , firstName : chen} });ajax(/ajax.php?funcreturnJson,{method : GET,callback : function(result){console.log(result);},data : {lastName : zernmal , firstName : chen} ,reciveType : json }); /script /body /html 以上只是简单实验如有问题欢迎提出。转载于:https://www.cnblogs.com/zernmal/p/3751066.html
http://www.yutouwan.com/news/1050/

相关文章:

  • 如何浏览国外网站?广告行业怎么找客户
  • 网站如何做关键词引流网站大图做多大尺寸
  • 建设信用购物网站asp网站模板源码免费无限下载
  • 一个人可以做多少网站注册一个500万的公司需要多少钱
  • 淄博网站制作建设优化朝阳网络公司
  • 在国内做跨境电商怎么上外国网站企业官方网站建设费用
  • 网站推广的方式?做网站给菠菜引流
  • 网站建设名牌网站编程语言
  • 网站目录改版文化体育局网站建设
  • 公司网站布局嘉定网站设计制作报价
  • 淄博论坛网站建设中山软件开发项目管理
  • 福州做网站多少钱苏州新港建设集团有限公司网站
  • 高端大气网站源码关于自己公司的网站怎么做
  • 东莞微信网站建设动态儿童摄影网站模板
  • 专业的网站建设公司排名教务系统学生登录入口
  • 做钓鱼网站用哪种编程语言销售管理系统软件哪个好
  • 免费下载ps素材网站网站过度优化
  • 景德镇市城市建设规划网站做网站推广需要花多少钱
  • 网络优化app大连网站优化方案
  • 做pc端网站平台做打折网站如何
  • 天合建设集团网站wordpress 评论函数
  • 大气个人网站源码重庆市建设网站
  • 模板网站与定制网站的价格网站建设的步骤及方法
  • 站内营销推广的案例网站建设理论基础
  • 宁德网站建设公司上海域邦建设集团网站
  • wordpress表单设计高级seo课程
  • 俄语网站模板济宁北湖建设局网站
  • 怎样创建自己公司的网站如何攻破wordpress
  • 在韩国申请网站域名需要什么泰安招聘信息最新招聘2022
  • 网站建设能够不同地方洛阳网站建设多少钱