1

I have big troubles dealing with a website I want to make a searchfunction for. It is a ranking in an online game, but the searchoptions are not enough for my alliance. Thus I want to make an ajax call getting the information needed, but there are several problems depending on what I tried:

  • If I try to make an ajax call as a JSONP-Call there's a "invalid label"-Error in my firebug. I already know that this error occurs because the retrieved data is not wrapped into a functioncall. Never the less I DO see the JSON data behind, why is it so far away for me?
  • If I try to make simple getJSON Calls using jQuery I get several errors all pointing at problems because of cross-site scripts. The JSON data is on another server, so that's a huge problem...

I personally am able to open the site directly correct (like www.onlinegamesite.com/api/?foo=foo&boo=false), if I'm able to open it in the browser, why am I unable to make it work pure programmatically?

I hope you have ideas how to deal with it, there are way too much threads about it in the WWW and after a day finding and trying again and again I finally hope for help in here.

EDIT: My current code is this one: (Trying for JSONP)

$(document).ready(function() {
var data = $.ajax({
    url: "http://lastchaos.gamigo.com/de/ranking/api/?tabNam=realm_4&CurrLang=de&CurrCategorie=user&sEcho=1&iColumns=6&sColumns=&iDisplayStart=0&iDisplayLength=1025&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=true&sSearch_4=&bRegex_4=false&bSearchable_4=true&sSearch_5=&bRegex_5=false&bSearchable_5=true&iSortingCols=1&iSortCol_0=0&sSortDir_0=asc&bSortable_0=true&bSortable_1=true&bSortable_2=true&bSortable_3=true&bSortable_4=true&bSortable_5=true",
    dataType: "jsonp"
    });
});

My last try before was some simple JSON Call, but I was unable to debug it properly (Couldn't stop FF filtering XSS while IE has no proper debugtools):

$(document).ready(function() {
var data = $.getJSON({
    url: "http://lastchaos.gamigo.com/de/ranking/api/?tabNam=realm_4&CurrLang=de&CurrCategorie=user&sEcho=1&iColumns=6&sColumns=&iDisplayStart=0&iDisplayLength=1025&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=true&sSearch_4=&bRegex_4=false&bSearchable_4=true&sSearch_5=&bRegex_5=false&bSearchable_5=true&iSortingCols=1&iSortCol_0=0&sSortDir_0=asc&bSortable_0=true&bSortable_1=true&bSortable_2=true&bSortable_3=true&bSortable_4=true&bSortable_5=true",
    type: "json"
    });
});
  • Look up the Same-Origin Policy. – SLaks Oct 14 '12 at 20:11
  • You should post your code so members can see where your error is. Please reword your question to make it concise / to the point, and put in your ajax code that you currently are having trouble with. – Eric Leroy Oct 14 '12 at 20:11
  • Here is a solution I made a couple weeks ago: http://stackoverflow.com/questions/12611469/get-list-of-jquery-ui-themes-from-an-url-same-origin-policy/12683349#12683349 – MLM Oct 14 '12 at 20:15
  • @MLM: Thanks! I got it working following your code example. I never thought about a workaround like this... :o SLaks: I know what it is, it is about getting the data anyway. –  Oct 15 '12 at 07:50

1 Answers1

2

You can do this by using this option

  1. make a call to php page
  2. make a curl request to another site
  3. grab the curl output data
  4. return the output data to ajax
  5. use that output data in your code
Marin Sagovac
  • 3,932
  • 5
  • 23
  • 53
StaticVariable
  • 5,253
  • 4
  • 23
  • 45
  • Thanks a whole lot! It's the same suggestion as the one by MLM above and it finaly works! It's a workaround, but now with a combination of curl and some eval I got it working. THANKS a lot! –  Oct 15 '12 at 07:48