When i perform request http://api.biblia.com/v1/bible/content/LEB.html.html?passage=John+1:1-3.16&key=[KEY]&style=fullyFormatted from browser i get correct text.
But when i perform same request from same computer but request performed as ajax query i get empty response page.
What could be wrong in this case. The key i use registered to the host i have installed
Hi Evgeny,
Web browsers enforce the Same Origin Policy, which requires that all ajax requests go to the same domain that the document was loaded from. A script running on mysite.com can only make ajax calls to other pages on mysite.com, but cannot make requests to yoursite.com, api.biblia.com, or any other domain.
The most common solution to this problem is to use JSONP, which is supported by the Biblia API. You will need to change the wrapping format to json, and add a callback parameter:
http://api.biblia.com/v1/bible/content/LEB.html.json?passage=John+1:1-3.16&key=[KEY]&style=fullyFormatted&callback=myCallback
Here, "myCallback" is the name of a javascript function in the global scope that will be called with the result of the query. If you're using jQuery, you can simplify your code a lot by using their built-in JSONP support:
$.ajax({
url: http://api.biblia.com/v1/bible/content/LEB.html.json?passage=John+1:1-3.16&key=[KEY]&style=fullyFormatted,
dataType: 'jsonp',
success: function(data){
$(data).appendTo('#container');
}
});
By setting the dataType property to 'jsonp', jQuery will generate the callback parameter for you and clean up after itself.
Let me know if you have any more questions.
Thanks,
Bryan