[AJAX] [PROGRAMMING] Ajax: Pop Up Blockers are an Ajax Developer Problem?
Errors you may never see, but exist!
Ajax: Pop Up Blockers are an Ajax Developer Problem?
Well pop up blockers have been known to drive developers insane when they block windows that are needed in the application. Well I just found out that some pop up blockers are destroying the lives of Ajax Developers too. I never thought that would be the case until I saw it with my own eyes.
As I always mention, I write all of the clientside errors to the server log on my application so I can spot problems that I would never see. The other week I saw an error message saying I had a bad response from the server. This check is a regular expression that expects a correct format from the server. When it detects an incorrect format it dumps the message to the log.
So in my log I see the error message and responseText string returned from the server. To my surprise I saw a wonderful injected code of a pop up blocker. The pop up blocker which I could identify was the Proxomitron Anti-popup code. The other blocker code I saw was too generic to determine what one it was.
So that means if you are expecting a certain format to be returned from the server, it may not be the case since a pop up blocker may inject code into the XHR response. That is why I stress you have to validate the data coming from your server on the client before using it. Make sure it is what you expect!
This is just one more thing to add to your plate when you are developing an Ajax application. Outside parameters you can not test for and can not control, but do affect your user’s experiences.
Eric Pascarello
Coauthor of Ajax In Action
Moderator of HTML/JavaScript at www.JavaRanch.com
Author of: JavaScript: Your Visual Blueprint for Dynamic Web Pages
EHF,
When I get a response back it should be a set string of numbers and such that is know to certain operations.
some basic example would be:
1,123,234;2,324,123;3,12;
Now instead of getting that my response was showing this in my log:
Client Error Message/Detail: ERROR: BAD RESPONSE FROM SERVER:
<!--//--><script>var PrxLC=new Date(0);var PrxModAtr=0;
var PrxInst; if(!PrxInst ) PrxRealOpen=window.open;
function PrxOMUp(){PrxLC=new Date();}function PrxNW(){
return(this.window);} function PrxOpen(.......
In the basic sense it is injecting the script into the page when it is requested. So the response being returned in my case would be:
--injected pop up code--My normal response I expect.
Now to get around that could be a little tricky depending on what you are doing. Could be as simple as placeing a wrapper around the response and getting it with some JS manipulation.
This post really goes in hand with my post back on Feb.13th with session expiring: http://radio.javaranch.com/pascarello/2006/02/13/1139887007801.html. The reponse coming back will be the login page. A lot of checks are needed and frameworks do not handle this!
Eric Pascarello