大家好,我从来没有遇到过谷歌无法解决的问题...... 所以这是代码:
function loadData(url, type){
loading_show();
var quality = getCheckedRadio();
$.ajax
({
type: "POST",
url: "http://.../core.php",
data: "url="+url +"&quality="+quality +"&type="+type,
success: function (msg)
{
$("#url").ajaxComplete(function(event, request, settings)
{
//loading_hide();
//$("input[type=button]").removeAttr("disabled");
$("#url").html(msg);
window.onload=$("#url").fadeIn('slow');
});
}
});
return false;
}
function getmp3(id){
var quality = getCheckedRadio();
$.ajax
({
type: "POST",
url: "http://.../core.php",
data: "id="+id +"&quality="+quality,
success: function (msgs)
{
$("#dload").ajaxComplete(function(event, request, settings)
{
loading_hide();
$("input[type=button]").removeAttr("disabled");
$("#dload").html(msgs);
window.onload=$("#dload").fadeIn('slow');
});
}
});
}
所以,第一个函数工作得很好,core.php返回一些html数据和一个javascript:“getmp3('bla');”因此它会触发第二个函数。问题是'getmp3'函数中的$ .ajax一遍又一遍地重复,它会泛滥浏览器。它做了它所拥有的,但它不会一次又一次地停止呼叫。
答案 0 :(得分:0)
您不需要ajaxComplete函数,可以将代码直接放在success函数中。
function loadData(url, type){
loading_show();
var quality = getCheckedRadio();
$.ajax
({
type: "POST",
url: "http://.../core.php",
data: "url="+url +"&quality="+quality +"&type="+type,
success: function (msg)
{
//loading_hide();
//$("input[type=button]").removeAttr("disabled");
$("#url").html(msg).fadeIn('slow');
}
});
return false;
}
function getmp3(id){
var quality = getCheckedRadio();
$.ajax
({
type: "POST",
url: "http://.../core.php",
data: "id="+id +"&quality="+quality,
success: function (msgs)
{
loading_hide();
$("input[type=button]").removeAttr("disabled");
$("#dload").html(msgs).fadeIn('slow');
}
});
}