我做了一個模塊,以在我的網站上使用jQuery/ajax腳本。爲此我使用了網站和其他網站上的例子。該腳本在IE中工作(爲了改變它在那裏工作),但我不能在FF或Safari瀏覽器中工作。嘗試了很多東西,但不知何故,它從來沒有執行updatecounter函數 我不是一個JavaScript程序員,所以不知道在哪裏看。也許有一些誰知道我做錯了什麼 試圖jQuery ajax調用不工作在FF和Safari瀏覽器在IE中工作
if (Drupal.jsEnabled) {
$(document).ready(function(content) {
$('a.download').click(function() {
// This function will get exceuted after the ajax request is completed successfully
var updatecounter = function(data) {
alert (data.counter); // only in IE this is displayed not in FF or Safari
}
alert(this.href); // this works in all browsers
var urlget = "/counter/get」;
$.ajax({
type: 'GET',
url: urlget,
success: updatecounter, // The js function that will be called upon success request
dataType: 'json', //define the type of data that is going to get back from the server
data: 'js=1' //Pass a key/value pair
});
//return false; // return false so the navigation stops here and not continue to the page in the link .. This puzzles me also. If I put it in the program stops and does not continue
});
});
}
奇怪的是,如果我改變它:
if (Drupal.jsEnabled) {
$(document).ready(function(content) {
$('a.download').click(function() {
// This function will get exceuted after the ajax request is completed successfully
var updatecounter = function(data) {
alert (data.counter); // only in IE this is displayed not in FF or Safari
}
var fout = function(stat, statext) {
alert (stat.readyState);
alert (statext);
}
alert(this.href); // this works in all browsers
var urlget = "/counter/get」;
$.ajax({
type: 'GET',
url: urlget,
success: updatecounter, // The js function that will be called upon success request
error: fout , // calls when error
dataType: 'json', //define the type of data that is going to get back from the server
data: 'js=1' //Pass a key/value pair
});
//return false; // return false so the navigation stops here and not continue to the page in the link .. This puzzles me also. If I put it in the program stops and does not continue
});
});
}
它總是轉到FOUT並顯示錯誤代碼4和文字錯誤。因此,Ajax調用工作,但給我總是和錯誤(僅在FF和Safari不是IE)
我想在這幾個小時也許有人可以幫助我在這裏 感謝
你有沒有想過這個? – 2010-04-03 06:46:11
你從'fout'警報中得到的錯誤是什麼? – 2010-07-13 19:21:43