Ajax在MVC 5中不起作用 [英] Ajax is not working in MVC 5

查看:137
本文介绍了Ajax在MVC 5中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我的项目有另外一个麻烦,我正在尝试做一个AjaxForm,但是没有用,有人知道那可能是什么?,这是我的代码......

< pre lang =HTML> @ Ajax.ActionLink(Create,Create,new AjaxOptions()
{
UpdateTargetId =UpdateContent,
InsertionMode = InsertionMode.Replace
})

< div id = UpdateContent style = < span class =code-keyword> text-align:center >

< / div >

@ section scripts
{
< script src = 〜/ Scripts / jquery.unobtrusive-ajax.min.js > < / script >
}





我一直在尝试在Asp.Net MVC 5中使用Ajax,但这是徒劳的,我已经包含了jquery.unobtrusive-ajax.min以及所有内容,当我包含所有内容并运行项目时,Visual Studio向我显示:



http:// localhost:4194 / Scripts / jquery.unobtrusive-ajax.min.js第5行第5行未处理的异常

0x800a1391 - Javascript运行时错误:'jQuery'未定义

解决方案

您好,



上面的代码似乎很好。朱st想确认你是否包含以下脚本?



jquery-1.7.1.min.js

MicrosoftAjax.js

MicrosoftMvcAjax.js


浏览器中的控制台可能会告诉您实际导致故障的错误。您可以在浏览器中使用该控制台,方法是按F12键,然后转到控制台。



每个错误都显示在控制台内部,告诉开发人员网站中的错误是什么。 Ajax错误,间接是导致的JavaScript错误,也是不执行命令集(函数)的原因。



您可以打开控制台,然后在尝试发送请求时检查控制台是在抱怨什么。如果没有,它将触发错误。确保选择正确的元素来运行请求。


Hello, I have another trouble in my project, I am trying to do an AjaxForm, but is not working, anyone knows what could be that?, here is my code...

@Ajax.ActionLink("Create", "Create" , new AjaxOptions()
{
    UpdateTargetId = "UpdateContent",
    InsertionMode = InsertionMode.Replace
} )

<div id="UpdateContent" style="text-align: center">
    
</div>

@section scripts
{
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
}



I have been trying to use Ajax in Asp.Net MVC 5 but it was in vain, i have included jquery.unobtrusive-ajax.min and everything, when i include everything and run the project, Visual Studio shows me this:

"Unhandled exception at line 5, column 2 in http://localhost:4194/Scripts/jquery.unobtrusive-ajax.min.js
0x800a1391 - Javascript Runtime Error: 'jQuery' is not defined"

解决方案

Hi,

The above code seems fine.Just want to confirm if you are including the below scripts?

jquery-1.7.1.min.js
MicrosoftAjax.js
MicrosoftMvcAjax.js


The Console from the browser might tell you the error that is actually causing a trouble. You can use that console from the browser, by pressing the F12 key and then going to the Console.

Each error is displayed inside the console, to tell the developer what is an error in the website. Ajax errors, indirectly are the JavaScript errors that were caused and were the reasons for non executing a command set (function).

You can open the console, and then check what the Console is complaining when you try to send a request. It will trigger an error, if it doesn't. Make sure you're selecting correct element to run the request.


这篇关于Ajax在MVC 5中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆