javascript - Json request working on safari but not chrome/firefox -
http://www.imobilus.co.uk/json%20request/index.html - live version
https://jsfiddle.net/5p6h3rtt/
cannot work out @ all, new jquery
works perfect on safari blank on chrome , firefox
$( document ) .ready(function() { $.ajax({ type: 'get', url: 'http://www.reed.co.uk/api/1.0/search?keywords=imobilus%20jobs', beforesend: function(xhr) { xhr.setrequestheader("authorization", "basic " + btoa(' b110030d-7491-48fe-9354-05c0ec0181d7' + ":" + '' )); }, data: { username: 'b110030d-7491-48fe-9354-05c0ec0181d7', password:'' }, datatype: 'json', success: function (data) { console.log(data.results); if(data.results.length > 0) { var numberofresults = data.results.length; $('.container').append('<div>found '+numberofresults+' results</div>'); $.each(data.results, function(index, element) { if(index < 100) { $('.container').append('<div class="my-class">'+element.locationname+'<div><div>'+element.jobdescription+'</div>'); } }); } else { $('.container').append('<div class="my-class">sorry nothing found</div>'); } } }); });
edit:
been messing ages , have got there works fine on chrome , firefox on ie/edge won't show @ , on safari browser asks authentication.
$( document ) .ready(function() { $.ajax({ datatype: 'jsonp', type: 'get', url: 'http://b110030d-7491-48fe-9354-05c0ec0181d7:@www.reed.co.uk/api/1.0/search?keywords=imobilus%20jobs', beforesend: function(xhr) { xhr.setrequestheader("authorization", "basic" + btoa( 'b110030d-7491-48fe-9354-05c0ec0181d7' + ":" + '' )); }, data: { username: 'b110030d-7491-48fe-9354-05c0ec0181d7', password:'' }, success: function (data) { console.log(data.results); if(data.results.length > 0) { var numberofresults = data.results.length; $('.reed').append('<div>found '+numberofresults+' results</div>'); $.each(data.results, function(index, element) { if(index < 100) { $('.reed').append('<div class="my-class">'+element.locationname+'<div><div class="my-class2">'+element.jobdescription+'</div>'); } }); } else { $('.reed').append('<div class="my-class">sorry nothing found</div>'); } } }); });
i checked code using datatype: 'jsonp'
, works fine in chrome well.
i tested in chrome , works. however, there problem on firefox authentication think not related this
$( document ) .ready(function() { $.ajax({ type: 'get', url: 'http://www.reed.co.uk/api/1.0/search?keywords=imobilus%20jobs', beforesend: function(xhr) { xhr.setrequestheader("authorization", "basic " + btoa(' b110030d-7491-48fe-9354-05c0ec0181d7' + ":" + '' )); }, data: { username: 'b110030d-7491-48fe-9354-05c0ec0181d7', password:'' }, datatype: 'jsonp', success: function (data) { console.log(data.results); if(data.results.length > 0) { var numberofresults = data.results.length; $('.container').append('<div>found '+numberofresults+' results</div>'); $.each(data.results, function(index, element) { if(index < 100) { $('.container').append('<div class="my-class">'+element.locationname+'<div><div>'+element.jobdescription+'</div>'); } }); } else { $('.container').append('<div class="my-class">sorry nothing found</div>'); } } }); });
Comments
Post a Comment