I've Django project on Dreamhost server that has several sights that returns Json response.Yesterday I've ported my Django project from local machine(localhost) to dreamhost server running apache.If I call my django view through jquery for

http://www.abc.com/projects/

It will return me all projects which i have during my mongodb database but rather than it returns :

On Opera - just headers without any response

Connection  Keep-Alive
Content-Type    application/json
Date    Thu, 19 Jan 2012 09:03:34 GMT
Keep-Alive  timeout=2, max=100
Server  Apache
Status  200 OK
Transfer-Encoding   chunked

On Chrome - No headers and response data.It throws a mistake:

XMLHttpRequest cannot load http://abc.com/Projects/. Origin null is not allowed by Access-Control-Allow-Origin.**

Basically just access the http://www.abc.com/projects/ through my web-browser it returns me leads to json format,although not just in case basically use JavaScript/Jquery.

Earlier I had been by using this middleware to permit other domain names to request and obtain response on my small local-machine with django in-built server.However after i am running on apache server It reduces and so i took it off from Configurations.py file.

I'm not sure why error coming .Help

*EDIT*

As @burhan recommended I made use of jsonp on client side and today my server is coming back json but browser is giving error before parsing it.Error is : unpredicted token

JSON i get in reply is :

{"projects": [{"projectName": "carmella", "projectId": "4f13c7475fcff30710000000"}, {"projectName": "SeaMonkey", "projectId": "4f1677b75fcff37c03000001"}]}

You're encountering the same origin policy sandbox. As your server is world wide web.abc.com and you're simply being able to access abc.com - the foundation isn't the same, and that's why the script isn't performing.

You've got a couple of options:

  1. Make certain the URL matches exactly - to prevent exactly the same origin policy sandbox.
  2. Use jsonp inside your javascript libary.