Cross domain access for JSON interface using AJAX

Bug #816607 reported by Sneetsher on 2011-07-26
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Alfanous - Quranic Search engine
Fix Released
Assem Chelli (عاصم شلي)

Bug Description


I'm using Chromium 12.0.742.112 (90304) Ubuntu 10.04.

Trying to access Alfanous JSON interface from JavaScript (jQuery). The browser prevents my script from retrieving data.

chromium js console:
XMLHttpRequest cannot load Origin null is not allowed by Access-Control-Allow-Origin.

As it is mentioned here:

A workaround is to add callback= to GET parameters

server reply must have 'Access-Control-Allow-Origin: *' in the HTTP header.

Changed in alfanous:
assignee: nobody → Assem Chelli (عاصم شلي) (assem-ch)
importance: Undecided → Critical
status: New → Incomplete
status: Incomplete → New

Salam ,

First ,thank you for submiting this bug. as i read it's about the browsers policy that restrict getting information from other websites.

I added this header to the service script:
    print "Content-Type: application/json; charset=utf-8"
    #Allow cross domain XHR
    print 'Access-Control-Allow-Origin: *'
    print 'Access-Control-Allow-Methods: GET'

Also I added this to .htaccess :
    Header set Access-Control-Allow-Origin *

I hope this helps.

Changed in alfanous:
importance: Critical → High
Sneetsher (sneetsher) wrote :

Yeah, it is working well now. Thank you.

Changed in alfanous:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers