C# ExtJS未收到来自POST的响应

C# ExtJS未收到来自POST的响应,c#,javascript,html,extjs,C#,Javascript,Html,Extjs,在浏览器中键入URL http://localhost/login/login.aspx时,我看到的响应是{success:true}。当我运行LoadMyHTML页面时,我可以从Fiddler和调试器中看到调用了aspx页面;但是,我的javascript没有返回任何内容,它将失败而不是成功 我在其他编程项目中也使用过这个url,但这是我第一次在ExtJS中使用它。我在网上看到了各种各样的例子,似乎没有一个能解决我的问题。下面是我的javascript文件,如果您能帮助我成功点击按钮返回,我们

在浏览器中键入URL http://localhost/login/login.aspx时,我看到的响应是{success:true}。当我运行LoadMyHTML页面时,我可以从Fiddler和调试器中看到调用了aspx页面;但是,我的javascript没有返回任何内容,它将失败而不是成功

我在其他编程项目中也使用过这个url,但这是我第一次在ExtJS中使用它。我在网上看到了各种各样的例子,似乎没有一个能解决我的问题。下面是我的javascript文件,如果您能帮助我成功点击按钮返回,我们将不胜感激

因此,即使fiddler显示调用是在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):


我按照你的建议做了,但它仍然以失败告终。到目前为止,我所看到的唯一的成功是来自。我甚至尝试使用JSFIDLE中的echo url来回显对代码的响应,但也失败了。您不能将表单提交到JSFIDLE,因为正如我所说,您必须提交到同一域上的URL。你能在控制台里看到错误信息吗?你肯定在你调试的代码中没有出现这样的错误,不是吗?哇,我觉得自己像个白痴。谢谢你花时间给我解释清楚。我不知道为什么跨域问题没有深入我的脑海。当然…现在我从localhost调用所有内容,它现在工作得非常好。再次感谢你的耐心!
Response.Write("{\"success\": true}");