0
我正在嘗試調用ASPX url;然而,回報不斷回落。無法從Ext JS調用aspx 4.2
我在其他編程項目中使用過這個URL,但這是我第一次將它與Ext JS結合使用。我在網上看到了各種示例,但似乎沒有解決我的問題。以下是我的JavaScript文件,任何幫助將得到我的按鈕點擊成功返回讚賞。
我已經使用了Fiddler,它調用了url;然而,即使認爲返回的JSON是{success:true},它不會觸及我的Debugger.Launch()語句或調用我的「成功」警報。
因此,它不會從javascript調用中輸入我的C#代碼,即使認爲fiddler顯示正在對http://localhost/login/login.aspx進行調用。
Ext.require([
'Ext.form.*',
'Ext.window.Window'
]);
Ext.onReady(function() {
Ext.QuickTips.init();
var field = new Ext.form.field.Text({
renderTo: document.body
}),
fieldHeight = field.getHeight(),
padding = 5,
remainingHeight;
field.destroy();
remainingHeight = padding + fieldHeight * 2;
var login = new Ext.form.Panel({
border: false,
fieldDefaults: {
msgTarget: 'side',
labelWidth: 100
},
defaultType: 'textfield',
bodyPadding: padding,
items: [{
xtype: 'box',
region: 'west',
width: 128,
height: 46,
autoEl: { tag: 'img', src: 'images/logo.png' },
style: 'margin: 10px 0px 15px 15px'
}, {
allowBlank: false,
fieldLabel: 'Company Name',
name: 'company',
emptyText: 'Company ID',
style: 'margin: 10px 0px 10px 30px'
}, {
allowBlank: false,
fieldLabel: 'User ID',
name: 'user',
emptyText: 'User Name',
style: 'margin: 10px 0px 10px 30px'
}, {
allowBlank: false,
fieldLabel: 'Password',
name: 'pass',
emptyText: 'Password',
inputType: 'password',
style: 'margin: 10px 0px 10px 30px'
}]
});
new Ext.window.Window({
autoShow: true,
title: 'Support Tools Login',
resizable: false,
closable: false,
width: 350,
height: 250,
layout: 'fit',
plain: true,
items: login,
constrain: true,
draggable: false,
buttons: [{
text: 'Login',
formBind: true,
handler: function() {
login.getForm().submit({
method: 'POST',
url: 'http://localhost/login/login.aspx',
waitTitle: 'Connectiong',
waitMsg: 'Sending data...',
success: function (login, action) {
Ext.Msg.alert('Success');
},
failure: function (login, action) {
Ext.Msg.alert('Failure')
}
});
}
}]
});
});
aspx文件:
using System;
using System.Diagnostics;
using System.Web;
using SupportToolsCommon;
namespace App.login
{
public partial class login : System.Web.UI.Page
{
private static Database db;
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.Write("{success: true}");
Response.End();
}
}
}
服務器響應什麼?提交操作期望具有「成功」屬性的json對象設置爲「true」。 – rixo
問題是,當我使用此代碼時,我沒有收到回覆。另外,我在我的aspx頁面的開始處設置了一個Debugger.Launch()語句。當我直接訪問網址時,它會啓動完美;但是,當我使用上述JavaScript時,它不會啓動。這告訴我,我在做POST時做了一些錯誤。 – mdupre1980
你不會陷入跨域問題?我的意思是,你的頁面實際上是從'https:// localhost/...'加載的?你是否至少在你的開發者工具中看到了傳出的請求? – rixo