I created a simple tracking script which adds the users info to a database when the page is unloaded. It works on all browsers except IE7 and IE6.
IE7 gives me errors, but I can't open the "debugger" because I'm using the standalone version (or at least that's what I think the problems is). I removed the async: false,
from the script below and I didn't get any errors, but I need async set to false in order for the script to work. Any ideas?
$(window).unload(function() {
$.ajax({
type: "POST",
async: false,
url: "add.php",
data: "ip=" + jIp + "&date=" + jD开发者_JAVA百科ate + "&time=" + jTime,
});
});
Your code has the following line:
data: "ip=" + jIp + "&date=" + jDate + "&time=" + jTime,
This code is broken in IE6/7, because there is a trailing comma in the object literal's property list. This is arguably legal Javascript, but is the source of no end of IE-specific errors. Remove the last comma and your call will work.
The comma at the end of this line, or just a typo in the post?
data: "ip=" + jIp + "&date=" + jDate + "&time=" + jTime,
精彩评论