larry*wei 2015-12-19 05:55 采纳率: 0%
浏览 20

阿贾克斯邮政电话不起作用

I am trying to call MVC Controller from jquery but not able to place the call. Is there any problem in below code Please figure out that if any problem and also I am not getting any error.

url="http://localhost:49917/Account/SaveAddress"

this.SaveAddress = function (url, addressData)
    {
            $.ajax({
                type: "POST",
                url: url,
                dataType: "json",
                data: JSON.stringify(addressData),
                contentType: 'application/json; charset=utf-8',
                success: function (responseDetail) {
                   },
                error:function(e)
                {

                },
            });
    return 0;
};

public async Task<ActionResult> SaveAddress(AddressListViewModel addressListVM)
    {
        bool response;
        string message;
        if (addressListVM.ID <= 0)
        {
            response = await Task.Run(() => AccountManager.Instance().AddAddress(addressListVM));
            message = response ? "New address added successfully." : "Failed to add new address.";
        }
        else
        {
            response = await Task.Run(() => AccountManager.Instance().UpdateAddress(addressListVM));
            message = response ? "Selected address updated successfully." : "Failed to update selected address.";
        }
        ModelState.Clear();
        return Json(new { responsestatus = response, message = message }, JsonRequestBehavior.AllowGet);
        //return PartialView("_AddressDetail", BuildAddressListEntity(
        //                                UserManager.FindById(User.Identity.GetUserId()), response, message, addressListVM.ID, true));
    }
</div>
  • 写回答

3条回答 默认 最新

  • helloxielan 2015-12-19 06:04
    关注

    Yes, you are missing a closing bracket at the end of the this.saveaddress function

      this.SaveAddress = function (url, addressData)
      {
            $.ajax({
                type: "POST",
                url: url,
                dataType: "json",
                data: JSON.stringify(addressData),
                contentType: 'application/json; charset=utf-8',
                success: function (responseDetail) {
                   },
                error:function(e)
                {
    
                },
            });
    

    after all of that .. you need one more closing bracket:

       }
    

    ;)

    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab