I was looking if there was a way to stop an already running AJAX request, like we can stop an http request using browser stop button. Yes there is a way to stop it using abort() method of the XMLHttpRequest object . More details about this here http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_a_1.html
Archive for the 'HTTP' Category
XMLHTTP AJAX abort(), jQuery abort()
March 10, 2011jQuery JSONP (JSON with padding) – success method not called
February 23, 2011Possible reasons for JSONP success method not getting called
-
In jQuery.getJSON method check if you are adding the
callback=?param to your URL -
Check if your server code serving JSONP request is returning proper JSONP response,
For example sample server JSONP java code and response taken from IBM Developerworks article given below,
Java code
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String jsonData = getDataAsJson(req.getParameter("symbol"));
String output = req.getParameter("callback") + "(" + jsonData + ");";resp.setContentType("text/javascript");
PrintWriter out = resp.getWriter();
out.println(output);
}
JSONP Response Format
jsonp1232617941775({"symbol" : "IBM", "price" : "91.42"});
To get a good understanding of JSONP you can read this IBM Developerworks article http://www.ibm.com/developerworks/library/wa-aj-jsonp1/
what http error code to use for validation error
February 18, 2011I was using 500 – Internal Server Error for validation errors, but problem was the application error handler caught this and shows generic error page, which causes validation logic to fail. So instead we can use
Either use code 400 – Bad Request
or code 200 – with the error message
http://stackoverflow.com/questions/362618/proper-use-of-http-status-codes-in-a-validation-server
Firefox addon to build HTTP request
January 17, 2011This needs comes up when you cannot test build HTTP GET or POST request requiring special request headers like content type = application/json;
Apache mod_rewrite NE|noescape
August 27, 2010I faced an issue where the URL for example /saved/ was getting rewritten to %2Fsaved%2F, which caused the web application to give 404 error because it expects the URL without escaped/encoded characters.
I found this Stack Overflow thread related to this problem which gave the solution,
http://stackoverflow.com/questions/2443115/apache-mod-rewrite-tomcat-encoding-26-and
Add NE flag to prevent escaping –
http://httpd.apache.org/docs/2.2/rewrite/rewrite_flags.html#flag_ne
Web Performance Test Tools
June 25, 2010jQuery AJAX multipart form-data file upload
June 21, 2010jQuery Form plugin provides AJAX form upload capabilities . Since XMLHttpRequest does not support upload , the plugin does it neatly using hidden iframe
IE 8 Browser Modes
May 25, 2010IE 8 Developer Tools gives a feature called Browser Modes, with which you can check how your web site works and look in IE 7 without having to install IE 7 . More about this feature here Testing in Different Browser and Document Modes
Firefox and IE Memory Profiler
May 19, 2010For Firefox, there is this addon more details about the tool here – Memory Profiler. But this addon is not available for Firefox 3.6.3, So if you are planning to use this plugin you have to install Firefox 3.5
For IE, you can use tool called Drip , and documentation about the tool usage and the common causes for memory leaks explained here