Ext.Ajax.Request在浏览器中不工作 [英] Ext.Ajax.Request not working in Browser

查看:219
本文介绍了Ext.Ajax.Request在浏览器中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ext.Ajax.Request似乎不适用于桌面网络浏览器。它在设备和xcode模拟器上工作得很好,但在桌面网络浏览器上,它会调用故障方法。这里是代码:

  //发送ajax请求
Ext.Ajax.request({
url :'http://testapp.cloudapp.net/index.php/api/accounts/login/',
method:'POST',
params:{
username:Ext.getCmp ('username')。getValue(),
密码:Ext.getCmp('password')。getValue()
},
dataType:'json',
success:函数(响应,请求){
if(response.responseText == true){
Ext.Msg.alert('validated');

//动画到墙视图
Ext.Viewport.animateActiveItem(targetView,{type:'fade'});

//破坏登录和注册视图
var vwRegister = Ext.ComponentQuery.query('注册')[0],
vwLogin = Ext.ComponentQuery.query('login')[0];

setTimeout(function(){
vwRegister.destroy();
vwLogin.destroy();
},2000);
}
else {
Ext.Msg.alert('invalid user');
}
},

失败:function(response,request){
Ext.Msg.alert('error');
}
});

我不认为这与同源政策有关,因为我试过使用jQuery的$ .ajax函数做同样的事情,它工作正常。

解决方案

检查调试控制台,你最有可能会看到关于相同原始政策的错误。



如果没有其他人尝试使用--disable-web-security选项打开chrome,看看它是否有帮助。



请参阅此问题以获取精确的语法。 / p>

祝你好运,Brad


Ext.Ajax.Request doesn't seem to work on desktop web browsers for me. It works perfectly fine on devices and on the xcode simulators but on desktop web browsers, it calls on the failure method. Here is the code:

// send ajax request
        Ext.Ajax.request({
            url: 'http://testapp.cloudapp.net/index.php/api/accounts/login/',
            method: 'POST',
            params: {
                username: Ext.getCmp('username').getValue(),
                password: Ext.getCmp('password').getValue()
            },
            dataType: 'json',
            success : function(response, request) {
                if(response.responseText == true) {
                    Ext.Msg.alert('validated');

                    // animate to wall view
                    Ext.Viewport.animateActiveItem(targetView, { type : 'fade' } );

                    //destroy Login and Register Views
                    var vwRegister = Ext.ComponentQuery.query('register')[0],
                        vwLogin = Ext.ComponentQuery.query('login')[0];

                    setTimeout( function() {
                        vwRegister.destroy();
                        vwLogin.destroy();
                    }, 2000);
                }
                else {
                    Ext.Msg.alert('invalid user');       
                }
            },

            failure: function(response, request) {
                Ext.Msg.alert('error');
            }
        });

I don't think this has something to do with the "Same-origin policy" because I tried doing the same thing using jQuery's $.ajax function and it worked fine.

解决方案

Check your debug console, you most likely will see an error about the same origin policy.

If nothing else try opening chrome with the --disable-web-security option to see if it helps.

See this question for exact syntax.

Good luck, Brad

这篇关于Ext.Ajax.Request在浏览器中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆