问题描述
我总是得到错误的警报。当我调试我得到的类型,网址为未定义。谁能帮助我,为什么这个方法是没有得到所谓的??
$(文件)。就绪(函数(){
$(#btnajaxcall)。点击(函数(){
$阿贾克斯({
键入:POST,
网址:Default.aspx的/ jQueryAjaxCalledMethod
的contentType:应用/ JSON的;字符集= UTF-8,
数据:{},
数据类型:JSON,
成功:函数(){警报('成功')},
错误:函数(){调试;警报(失败);返回false; }
});
});
});
[的WebMethod]
公共无效jQueryAjaxCalledMethod()
{
//一些code HERE
}
大家好我只是用与谷歌托管的jQuery的文件。
它制定了罚款。
previously我是使用jQuery 1.7.1版本,我已经下载并存储在我的地方。我也看到了很多的问题的论坛,这个特殊的Ajax调用相当不能正常使用.NET 4.发生的事情,我不知道和原谅我,如果我错了,但我有一种感觉,1.7.1在这种情况下无法正常使用ASP.NET 4.工作
P.S - >我在脚本标签中使用此 - >
SRC =http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
Always i get the alert in the "error". When i debugged i get the type,url as undefined. can anyone help me why that method is not getting called??
$(document).ready(function () {
$("#btnajaxcall").click(function () {
$.ajax({
type: "POST",
url: "Default.aspx/jQueryAjaxCalledMethod",
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: 'json',
success: function () { alert('success') },
error: function () { debugger; alert('failure'); return false; }
});
});
});
[WebMethod]
public void jQueryAjaxCalledMethod()
{
//SOME CODE HERE
}
Hi all i just used the jquery file hosted with google.
It worked out fine.
Previously i was using the jquery version 1.7.1 that i had downloaded and stored in my local. I also saw a lot of questions in the forum that this particular ajax call is quite not happening properly with .NET 4. I am not sure and forgive me if i am wrong but i do have a feeling that 1.7.1 in this case is not properly working with ASP.NET 4.
P.S -> I used this in the script tag --> src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
这篇关于jQuery的Ajax调用不调用在.CS文件中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!