jquery - json parsing not working on mozilla firefox browser -
i have written $.ajax function make api call. result displayed on chrome browser. result of api call not gets displayed on firefox browser. ajax call not work @ in ie browser. can please advise why issue coming.
following code have used:
var seriesurl = "http://t2json.tgoservices.com/818746/printermanufacturers/21/printerseries"; $.ajax({ cache: false, url: seriesurl }).done(function (data, textstatus, jqxhr) { $.each(data, function (i, item) { var items = item.printerseries.items; (var = 0; < items.length; a++) { var id; $("#content1").html('<a class="manufacturer" onclick="getprinter(' + items[a].id + ',' + n + ');" id="' + items[a].id + '" style="cursor:pointer;" >' + items[a].name + '</a>'); } }); }).fail(function (jqxhr, textstatus) { $('#status').html(textstatus); $('#content').html('(failed)'); });
i think issue stems not defining datatype on initial ajax request.
if(!window.console) console = {log:function(){}}; function getdata(){ var seriesurl = "http://t2json.tgoservices.com/818746/printermanufacturers/21/printerseries"; $.get(seriesurl,function(data){ console.log(data); var items = data.t2json.printerseries.items; console.log(items); for(var = 0; < items.length; a++) { $("#content1").append('<a class="manufacturer" onclick="getprinter('+items[a].id+');" id="'+items[a].id+'" style="cursor:pointer;" >'+ items[a].name + '</a><br>'); } },'json'); //--datatype definition (json, jsonp, html, xml, etc...) } please note modified code slightly. there "n" variable within generated anchor tags not defined in code snippet, removed example.
if prefer use ajax shorthand, need add datatype:json setting.
Comments
Post a Comment