I made a little module to use a jquery/ajax script on my website. For that I used examples which are on the site and others. The script is working in IE (for a change it works there) but I cannot get it working in FF or safari. Tried a lot of things but somehow it never executes the updatecounter function I am not a javascript programmer so have no idea where to look. Maybe there are some who know what I am doing wrong Tried
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
});
});
}
Strange thing is if I change the it to :
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
});
});
}
It always goes to fout and displays error code 4 and text error. So the ajax call is working but gives me always and error (only in FF and safari not in IE)
I am trying on this for some hours maybe someone can help me out here Thanks