Problem with Ajax Request and Escape
Hello.
First of all, I'm German, so be warned ;)
I've got a problem and my very hope are you guys (and girls).
Here is my code I use to make a ajax request:
-
$.ajax(
$.extend(ajax, {
data: { cmd:'ping', username:session.username,
timestamp:ping.last },
error: function() { that.notifyPingingFailed(); },
success: function(data) {
if(data.error) { that.notifyPingingFailed(); }
else { that.notifyPingingFinished(loadResponse(data)); }
}
})
);
Don't wonder about the $.extend cause I make this kind of request more
than one time and so I've exclude some basic options.
You can see I make a request called 'ping' and exatly this request
tries 30s seconds to get new data from server (PHP). If there are no
changes, the request will return an empty array otherwise the new data
as json.
After that, the request will be called again.
Now my problem:
If I press the escape-button, the request will be canceled. That's
pretty uncool because there's no new request.
Can anyone of you help me?
I've tried to catch the escape-press event this way:
-
$(document).keyup(function(e) {
if(e.keyCode == 27) {
return false;
}
}
But this isn't helpful cause the request will be still canceled.
Need your help, really ;)[/code]