AppCan里面的Ajax通信实例

<!DOCTYPE html><html class="ui-mobile landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px"> <head> <title> </title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> <link rel="stylesheet" href="css/ui-media.css"> <link rel="stylesheet" href="css/ui-base.css"> <link rel="stylesheet" href="css/ui-apple.css"> <script src="js/zy_anim.js"> </script> <script src="js/jquery.js"> </script> <script src="js/zy_control.js"> </script> <script src="js/zy_tmpl.js"> </script> <script> zy_fix("header","footer",0,function() { /*请在此插入网页初始化代码*/ });   function xmlHttp(){     var url = document.getElementById('add').value;     uexXmlHttpMgr.open("1", "GET", url, '');     uexXmlHttpMgr.send("1"); }   function httpSuccess(opid,result,data){ document.getElementById('adre').innerHTML = "opCode:" + opid + "<br> result:" + result + "<br>data:" + data; uexXmlHttpMgr.close("1"); }   window.uexOnload = function(){     uexXmlHttpMgr.onData = httpSuccess;     uexWidgetOne.cbError = function(opCode, errorCode, errorInfo){       alert("errorCode:" + errorCode + "\nerrorInfo:" + errorInfo);   } } </script> </head> <body class="ui-mobile-viewport" > <!--header开始--> <div id="header" data-role="header" class="ui-header ui-bar-c ui-header-fixed ui-bar-glass" > <h1 class="ui-title" tabindex="0" role="heading" aria-level="1"> AppCan </h1> </div> <!--header结束--> <div id="page_0" class="ui-page ui-body-d ui-page-active" tabindex="0"> <!--content开始--> <div class="tit">跨域异步请求接口</div>     <div class="conbor">     <div class="consj">     <span>跨域异步请求接口测试:</span>     <span>注:测试地址为蝌蚪项目首页信息地址,返回服务器的原始数据。</span>     <span>请求内容:</span>     <div class="tcxx" id="payy">       <input class="textbox" type="text" id="add" value="http://www.kedo.gov.cn/mobile/index/GetIndexInfo.jsp?jsoncallback=?&type=1">     </div>     <input class="btn" type="button" value="取数据" οnclick=xmlHttp()>     <span>请求结果:</span>     <div class="tcxx" id="adre"></div>     <input class="btn" type="button" value="返回" οnclick="uexWindow.back();">     </div>     </div> </div> <!--content结束--> <!--footer开始--> <div id="footer" data-role="footer" class="ui-footer ui-bar-a ui-footer-fixed"> <h1 class="ui-title ui-smaller" tabindex="0" role="footer" aria-level="1"> (c) Copyright 3G2WIN and others 2011.<br> All rights reserved. </h1> </div> <!--footer结束--> </body> <script> zy_init(); </script></html>

主要是注意各个参数都是必填的。返回的data是主要数据。
在AppCan中不能用Jquery的Ajax主要是因为静态页是不能提交跨域请求的。浏览器会解析成file://这种格式,而不是http://

本文固定链接: http://www.stevezheng.com/archives/211 | SteveZheng | 没有执行力,梦想算个屁

具体:http://www.verydemo.com/demo_c107_i12597.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值