sencha touch ajax params,sencha touch实现ajax跨域请求

【环境说明】

1、sencha touch : 2.3.1

2、play : 2.2.0

3、chrome

【代码示例】

1、sencha touch

Ext.Ajax.request({

url:‘http://10.228.190.97:9000/login‘+"/"+userName+"/"+password,

useDefaultXhrHeader : false,

success: function(result, request) {

var respText = Ext.JSON.decode(result.responseText);

alert(respText.email);

}

});

2.1、play   -- UserController.java

@With(CorsAction.class)

public class UserController extends Controller{

@Transactional

public static Result login(String _dc, String username, String userpwd) {

Contact contact = Contact.login(username, userpwd);

return ok(parser(contact));

}

}

2.2、play   -- CorsAction.java

public class CorsAction extends Action.Simple {

public Promise call(Context context) throws Throwable{

Response response = context.response();

response.setHeader("Access-Control-Allow-Origin", "*");

response.setHeader("Access-Control-Allow-Headers","X-Requested-With");

return delegate.call(context);

}

}

【截图演示】

93671bd7320b760bb45745cc5646dc79.png

0e41af0d1153bb4ed00512de167e71b4.png

原文:http://blog.csdn.net/lmtony/article/details/19906141

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值