weixin_33716941 2015-01-31 12:45 采纳率: 0%
浏览 4

Ajax URL-错误的.net #c

Been following some tutorials, as i'm learning C#, however was just attempting to make an ajax call to the server, i'm using my localhost.

As far as I can tell i'm doing its right, but it's obviously not. Maybe it my folder structure or just the name of the file.

Folder Structure

The Default.aspx file is at the project root Here is my ajax call

        $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "Default.aspx",
        dataType: "json",
        data: "{'FirstName':'test','LastName':'test1','City':'test3','EmailID':'test4'}",
        success: function (data) {
            console.log("Woo!");
        },
        error: function (result) {
            console.log("fail!");
        }
    });

I know eventually it will have to call a method within the file, but its not even finding it at the moment.

Thanks in advance, James

  • 写回答

1条回答 默认 最新

  • weixin_33736832 2015-01-31 12:56
    关注

    You can use controller Home and create the one action.

    Example:

    public ActionResult FirstAjax()
    {
        return Json(true, JsonRequestBehavior.AllowGet);
    }   
    

    After that your jquery ajax is:

    $.ajax({
            type: "GET",
            contentType: "application/json; charset=utf-8",
            url: "Home/FirstAjax",
            dataType: "json",
            data: "",
            success: function (data) {
                console.log("Woo!");
            },
            error: function (result) {
                console.log("fail!");
            }
        });
    
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大