0
我試圖開發一個互動網站後不會觸發和我被困在其中一個文件應該被添加和executed.So我在扉頁以下代碼點:Javascript代碼加載
$(document).ready(function(){
$('.info').live("click",function()
{
if ($('#country span.selected').text().length == 0)
alert("A company should be selected before continue!");
else {
$('.centered').hide();
$('.waitimg').show();
$.post('get_data.php',
{
type :$(this).attr("id"),
company : $('#country span.selected').text(),
company_id : $('#country').attr("value"),
country : $('#scountry span.selected').text(),
industry: $('#industry span.selected').text()
}, function(response)
{
//$('#resultarea').fadeOut();
setTimeout("finishAjax('resultarea','"+escape(response)+"')", 400);
}
);
}
return false;
});
});
和回調:
function finishAjax(id, response) {
$('#waitimg').hide();
$.getScript("js/script.js");
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
}
它應該執行從JS /的script.js腳本,但事實並非如此。使用Firebug我可以看到文件被加載,但是在script.js中沒有被觸發,只是處於簡單警報狀態(「hello world」)。爲什麼?
嘗試,這是行不通的。 –
@StackOverfolow:我不是精神病患者,所以我不知道你的頁面是什麼樣的,或者其他代碼可能導致問題。 [嘗試設置一個小提琴](http://jsfiddle.net),所以我們可以看到你已經嘗試 –
響應是好的,我的問題是,script.js中的代碼根本沒有執行。 –