[英]ExtJS not receiving response from POST
當我在瀏覽器中鍵入URL http://://localhost/login/login.aspx時,我看到的響應是{成功:true}。 當我運行我的html頁面時,從Fiddler和調試器中可以看到aspx頁面被調用; 但是,什么也沒有返回我的JavaScript,而是轉到FAILURE而不是SUCCESS。
我已經在其他編程項目中使用了此url,但這是我第一次將其與Ext JS一起使用。 我在網上看到了各種示例,但似乎都沒有一個能解決我的問題。 以下是我的javascript文件,對您的按鈕單擊成功返回的任何幫助將不勝感激。
因此,即使認為提琴手顯示正在對http://://localhost/login/login.aspx進行調用,也不會從javascript調用中輸入我的C#代碼。
任何幫助將不勝感激。
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();
}
}
}
default.html頁面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Login Page</title>
<!-- ExtJS -->
<script type="text/javascript" src="extjs/ext-all.js"></script>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="css/support-tools.css" />
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="scripts/login.js"></script>
</head>
<body id="login-page"></body>
</html
嘗試替換此行:
Response.Write("{success: true}");
格式良好的JSON(屬性名稱必須全部用JSON中的引號引起,而不是JavaScript):
Response.Write("{\"success\": true}");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.