mam problem albo zgłupiałem zmęczony tematem
robei zapytanie GET po jakis tam adres:
$.ajax({ type: 'GET', url: 'tu ten adresik/search', cache: false, dataType : 'script', //ale jsonp tez działa, reszta (np text) wywala bład data: {cb: 'jQuery18303185707158409059_1370954922211', q: 'cl', lang: 'en', _ : timest}, success: function(html){ alert(html); }, error: function(data, status){ alert('error: -> ' + status); } }); });
zapytanie jest ok, tzn firebug pokazuje co sie dostało spowrotem, a mianowicie jest to json o postaci
jQuery18303185707158409059_1370954922211({'data': {'QueryTerm': 'cl', 'Language': 'en', 'SuggestionItems': {0: {'Category': '', 'Weight': '99', 'Suggestion': 'cloud'}, 1: {'Category': '', 'Weight': '35', 'Suggestion': 'cloud security'}, 2: {'Category': '', 'Weight': '30', 'Suggestion': 'cloud development'}, 3: {'Category': '', 'Weight': '30', 'Suggestion': 'cloud application delivery'}, 4: {'Category': '', 'Weight': '25', 'Suggestion': 'cloud service automation'}, 5: {'Category': '', 'Weight': '25', 'Suggestion': 'cloud management'}, 6: {'Category': '', 'Weight': '20', 'Suggestion': 'client automation'}, 7: {'Category': '', 'Weight': '18', 'Suggestion': 'clip'}, 8: {'Category': '', 'Weight': '18', 'Suggestion': 'closed loop incident process'}, 9: {'Category': '', 'Weight': '18', 'Suggestion': 'closed loop incident process (clip)'}}}})
w firebugu mozna nawet podgladnąc sobie ten obiekcik
Mam dwa pyatnia
1. dostaje błąd: ReferenceError: jQuery18303185707158409059_1370954922211 is not defined , pytanie czemu?
2 najwazniejsze... jak dostać się do danych w tym obiekcie.... potrzebuje wyciągnąc wszystkie elementy "Suggestion"
czy problem jest w tm ze sa tam pojedyncze quotes a nie podwójne.
Każda sugestia mile widziana.