0

Im trying to retrieve a feed or at least get a success, but for some reason it's not working for me. Please help

$(function() {
  $.ajax({
    url: 'http://www.canadiantire.ca/ws/ajax_call.jsp?proc_class=com.ctc.ajax.CTCRequestAjaxHandler&action=getTabProductInfo&locale=en&pTab=1&pSku=0853086,0853694,0853693,0853076,0853082,0853662&callback=?',
    type: 'GET',
    dataType: 'jsonp',
    jsonp: 'jsonp',

    success: function(data) {
      alert('success');

    },
    error: function() {
      alert("Sorry, I can't get the feed");
    }
  });
});

2 Answers2

1

You can simply open that URL in browser and see it is not returning jsonp. SOme API's that do serve jsonp require a specific callback value or other parameters to be sent. Not all API's do serve jsonp though. See API docs.

If you try to request as json, you get a cross domain error since server is not CORS enabled.

Not all API's are accessible via ajax and the fallback is to use a proxy

charlietfl
  • 164,229
  • 13
  • 110
  • 143
0

try to add this inside ajax call. Reference http://learn.jquery.com/ajax/working-with-jsonp/

 data: { format: "json" },
Lumi Lu
  • 3,213
  • 1
  • 9
  • 20