Archive for July, 2009

Jquery Ajax Returning Null / Not Working

I was working with jquery.ajax yesterday and today and it just wasn’t working for me.  It was starting to get very frustrating because it was a very very very simple code snippet.  I have used this numerous times before with no problems.

So to debug it, I started watching all of my Apache Logs and saw that instead of a GET request, I was getting an OPTIONS request.  This was strange, so I thought that maybe I just have to set the ajax type property to GET.  Tried that to no avail, same request type.

Upon further research, I found that it was because I was trying to hit a different domain instead of the one I was on.  I setup a quick proxy through my domain and everything worked like a charm. 

After writing this post I read this NOTE on the jQuery site.

Note: All remote (not on the same domain) requests should be specified as GET when ’script’ or ‘jsonp’ is the dataType (because it loads script using a DOM script tag). Ajax options that require an XMLHttpRequest object are not available for these requests. The complete and success functions are called on completion, but do not receive an XHR object; the beforeSend and dataFilter functions are not called.

This site hosted by - Find the best deals on Bowling Balls, Bowling Bags, Bowling Shoes, and Bowling Accessories.