jquery ajax 为什么没执行......................................................新手在线求解
$(".titleBack").each(function () {
$(this).bind("click", function () {
var titleId = $(this).attr('id');
$.ajax({
type: "post",
url: "../CallingPage/titleBackColorCalling.aspx?iTitle='" + titleId + "'",
data: null,
datatype: "json"
});
});
});
$(".format").each(function () {
$(this).bind("click", function () {
var formatId = $(this).attr('id');
$.ajax({
type: "post",
url: "../CallingPage/reviseFormatCalling.aspx?formatName='" + formatId + "'",
data: null,
datatype: "json"
});
});
});
titleBack 和 format 是<a>的class属性
为什么 format 执行了
titleBack 没有执行titleBackColorCalling.aspx页面
[最优解释]
如果路径都没问题的话,请检查 titleBackColorCalling 名称和aspx.cs的命名保持一致
------其他解决方案--------------------
$(".titleBack").each(function () {
$(this).bind("click", function () {
var titleId = $(this).attr('id');
$.ajax({
type: "post",
url: "../CallingPage/titleBackColorCalling.aspx?iTitle='" + titleId + "'",
data: null,
datatype: "json"
});
});
});
$(".format").each(function () {
$(this).bind("click", function () {
var formatId = $(this).attr('id');
$.ajax({
type: "post",
url: "../CallingPage/reviseFormatCalling.aspx?formatName='" + formatId + "'",
data: null,
datatype: "json"
});
});
});
[其他解释]
确保class存在的情况下,看看$(this).attr('id')是否有出错
[其他解释]
$(this).attr('id')通过firefox测试没问题
使用vs 断点调试 根本没跳进titleBackColorCalling.aspx
不知道为什么
------其他解决方案--------------------
bind在一个页面有使用次数限制吗?
[其他解释]
这个你自己把路径没有写对吧。试着用绝对路径:类似/xxxx/xxxx/titleBackColorCalling.aspx
[其他解释]
没有限制
[其他解释]
$(".titleBack").bind("click", function () {
//.....
});
这样就好了,jQuery本身就是集合操作,没有必要再 each
[其他解释]
绝对路径也不能够啊