weixin_33709219 2017-08-10 15:41 采纳率: 0%
浏览 29


My intention is to update a database without completely reloading the current page the user is on when the user submits the data, instead just popping a message box saying success or failure, or something like that.

I have the following JS function which is called when the user clicks a button.

function saveListItem(formID)
    alert('JS function fired.');
    var _form = $('#mainForm' + formID)
    var _formData = _form.serialize();

        dataType: "json",
        type: "POST",
        url: "/Postings/listItemSubmitted",
        contentType: "application/json; charset=utf-8",
        data: { type: "test" },
        success: function () {
        error: function (xhr, status, error)

And here is the controller action:

public JsonResult listItemSubmitted([FromBody] string type)
    type += "!!!";
    return Json(type);

As you can see, I have a few variables that I later intend to use to actually do something. But for now, I'm just trying to get just this TEST to work. The problem is that the action in the controller will not even fire. The error alert gives me "Bad Request."

I've checked the names, all of the names are correct(controller is PostingsController.cs, method name is listItemSubmitted). I've tried every combination of slashes before and after words in the URL syntax. I've even tried using the @Url.Action method, which gave me that string anyway, so I know it's correct.

I don't know what else to try. Does anyone know what is going on?

  • 写回答



      相关推荐 更多相似问题


      • ¥15 Android URL如何转成视频/音频,可行吗?
      • ¥20 SQL数据查询,子查询
      • ¥15 c++字符串分割问题
      • ¥15 关于#sql#的问题:没有用命令关闭cdc,手动把系统表开启的cdc右键删除了
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题