0

I am trying to retrieve the data when i call a query to get the nearest Dominoes Outlet.

This is my code for that call :

var echo = function(dataPass) {
    $.ajax({
        type: "POST",
        url: "/echo/json/",
        data: dataPass,
        cache: false,
        success: function(json) {
            console.log("It's a success, folks!");
        }
    });
};

$('.list').live('click', function() {
    $.get("http://www.dominos.co.in/outlet?city=AMRITSAR&restaurent=DP66001", function(data) {
        var json = {
            json: JSON.stringify(data),
            delay: 1
        };
        echo(json);
    });
});

Normally if the call is successful, i will get a google map representation of the nearest Dominoes shop . For that I am using Dominoes locator : http://www.dominos.co.in/outlet?city=AMRITSAR&restaurent=DP66001

But, when i run it in fiddle i get the following error :

XMLHttpRequest cannot load http://www.dominos.co.in/outlet?city=AMRITSAR&restaurent=DP66001. Origin http://fiddle.jshell.net is not allowed by Access-Control-Allow-Origin.

FIDDLE : http://jsfiddle.net/YUWB2/154/

Where am i going wrong ?

EDIT : I know this is happening due to Same Origin Policy, what i want to know is whether there is any alternative way of doing it ?

The Dark Knight
  • 5,455
  • 11
  • 54
  • 95
  • @tymeJV : I know about SOP, My question rather is : Can we bypass it ? – The Dark Knight Oct 01 '13 at 13:16
  • Gotcha, do you know for sure that their site allows `get` calls? – tymeJV Oct 01 '13 at 13:17
  • @tymeJV : Is there any way to know whether any site allows `gets` ? – The Dark Knight Oct 01 '13 at 13:18
  • Ehh...normally the site will say I'm pretty sure, I just tried a quick google for it but not seeing much' – tymeJV Oct 01 '13 at 13:19
  • @tymeJV : Yes, before URLing that , i also tried to find that out in their site, but not much information was given there , except `pizzas` :) – The Dark Knight Oct 01 '13 at 13:20
  • You might be able to use JSONP. If not, there is no solution (because the dominoes website needs to allow cross origin requests). – jgroenen Oct 01 '13 at 13:22
  • **I wrote an answer for this question here: [Loading cross domain html page with jQuery AJAX](http://stackoverflow.com/questions/15005500/loading-cross-domain-html-page-with-jquery-ajax/17299796#17299796)** – _the last one, supports https_ – jherax Jun 26 '14 at 15:03

1 Answers1

0

You might be able to use JSONP. If not, there is no JavaScript solution, since the server must allow cross origin requests. You could build a proxy server that does, though.

jgroenen
  • 1,332
  • 1
  • 8
  • 13