目录

$service

与服务器服务处理

$service.get()

以get方式向服务器索求数据的请求

代码演示

  1. $service.get({
  2. "url" : "http://opentest.yonyoutelecom.cn/mobile/isvName.do?account=qinfx&q=",//必选参数,get请求的URL
  3. "callback" : function (sender,args){
  4. //返回结果类型为对象,键值为resule的结果类型为json数组格式的字符串类型。
  5. var str=args.result;
  6. var arr=(eval(args.result)[1];
  7. var obj=eval(args.result)[1].text;
  8. }/*,
  9. "header":{
  10. "Content-Type":"application/x-www-form-urlencoded",//可选参数,方便开发者设置请求的header
  11. "User-Agent":"imgfornote"
  12. },
  13. "timeout" : "5"*//可选参数,超时时间,单位为秒
  14. })

$service.post()

以post方式向服务器索求数据的请求

代码演示

  1. $service.post({
  2. "url" : "http://opentest.yonyoutelecom.cn/mobile/isvName.do?account=qinfx&q=",//必选参数,post请求的URL
  3. "callback" : function (sender,args){
  4. //返回结果类型为对象,键值为resule的结果类型为json数组格式的字符串类型。
  5. var str=args.result;
  6. var arr=(eval(args.result)[1];
  7. var obj=eval(args.result)[1].text;
  8. }/*,
  9. "data" : {a:1,b:2},//可选参数,post请求的要写入的条件数据,须为json对象
  10. "header":{
  11. "Content-Type":"application/x-www-form-urlencoded",//可选参数,方便开发者设置请求的header
  12. "User-Agent":"imgfornote"
  13. },
  14. "timeout" : "5"*//可选参数,超时时间,单位为秒
  15. })

用例github下载地

文档更新时间: 2018-01-15 14:26