weixin_33709364 2013-07-12 15:04 采纳率: 0%
浏览 48

MVC4 Ajax jQuery 2

Does anyone know what I need to get the ajax.beginform to work in my MVC4 project? I updated the jQuery library to version 2 and I have included the jquery.validate.js and jquery.validate.unobtrusive.js but the form is still posting to the new page rather than just updating the UpdateTargetId element

I have had a google and a lot of people seem to be having problems with a script called Microsoft.jQuery.Unobtrusive.Ajax but this isn't in my project. Do I need to install this, and if so do I then need to do a find and replace on live so that it uses on instead?

This is the form code:

@using (Ajax.BeginForm("AddImage", "Quote", FormMethod.Post, new AjaxOptions { UpdateTargetId = "Files" }, new { enctype = "multipart/form-data" }))
{
}

This posts to the quote controller addimage action and all that does is write out a string to the screen (which should appear in the Files div) but instead of doing an ajax call it is actually going to the Quote/AddImage page

  • 写回答

2条回答 默认 最新

  • hurriedly% 2013-07-12 20:19
    关注

    First, you're missing InsertionMode in your AjaxOptions.

    Second, it seems you're trying to upload files using Ajax form? You won't be able to. Please see this post, for example.

    Finally, Ajax.BeginForm is using jQuery.live() function, which has been removed as of jQuery version 1.9. See this question for more info.

    You should install jQuery Migrate Plugin which will restore deprecated features. This will at least restore your Ajax form functionality. Alas, it won't help you upload files through Ajax. But that's a different topic.

    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题