mvc4 empty().html,MVC4 Unobtrusive AJAX BeginForm Internet Explorer DIV清空 - jquery代码 - 源码查...

本文介绍了一项关于在Internet Explorer 8中使用无侵入式AJAX更新MVC4应用内DIV元素的问题及解决方案。作者在Chrome和Firefox中实现了功能,但在IE8中遇到了显示空白的问题。通过仔细检查HTML标签对齐情况,最终解决了这一难题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题

I wonder if anyone can help me. I am attempting to add unobtrusive AJAX to my MVC 4 application. I have the following scripts added to my page.

The Unobtrusive AJAX library is a NUGET package version 3.2.0

I have a DIV that I'm attempting to update via AJAX, simplified as shown below.

@using (Ajax.BeginForm("MyAction", "MyController", new AjaxOptions { UpdateTargetId="MainForm", HttpMethod = "POST" }))

{

}

Then I have a controller to return a partial view into the DIV.

[HttpPost]

public ActionResult MyAction(Models.WhateverModel MyModel)

{

return PartialView("MyPartialView");

}

You click the submit button and in Chrome and Firefox this works fine, the div MainForm is updated with the contents of my returned partial view.

I put a break point in on my action, when run in IE8, the server side action code is reached, but the MainForm DIV ends up empty.

I turned script errors on in IE8, but no script errors occur.

I also tried switching to jQuery 1.11.1 but this did not help.

I've been searching around in the forums and I can't find an obvious fit for this issue.

Any ideas?

解决方法

After a further two hours of searching, I found a post that suggested making sure that all your HTML tags are in correct alignment.

The suggestion was that internet explorer is less able to deal with incorrectly formed HTML.

After checking my page using the HTML validator plugin for firefox I found I had a div tag out of alignment.

Once I fixed that everything started working correctly in internet explorer.

Leaving this here as it may help someone else who has the same issue.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值