php - Cross-domain AJAX request error on HTTP 200 -


i'm writing basic facebook app, i'm encountering issue cross-domain ajax requests (using jquery).

i've written proxy page make requests graph via curl i'm calling via ajax. can visit page in browser , see has correct output, requesting page via causes jquery fire error handler callback.

so have 2 files:

proxy, curl request

<?php //do curl requests, manipulate data //return json print json_encode($data); ?> 

the facebook canvas, contains ajax call

$.getjson("http://mydomain.com/proxy.php?get=stuff",            function(json)           {               alert("success");           })           .error(function(err)           {               alert("err");           }); 

inspecting call firebug shows returns http code 200 ok, error handler fired, , no content returned. this happens whether set content-type: application/json or not.

i have written json-returning apis in php before using ajax , never had trouble.

what causing request trigger error handler?

recently experienced same issue , problem fact there domain difference between webpage , api, due ssl.

the web page got http address (http://mydomain.com) , content requesting jquery on same domain https protocol (https://mydomain.com). browser (chrome in case) considered domains differents (the first 1 http, second 1 https), because of protocol, , because request response type "application/json", browser did not allowed it.

basically, request worked fine, browser did not allowed response content.

i had add "access-control-allow-origin" header make work. if you're in same case, have there: https://developer.mozilla.org/en/http_access_control.

i hope that'll you, got headache myself.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -