Sriker Ch Sriker Ch - 5 months ago 13
Javascript Question

Sort returning different results in different browsers

function sort(type) {
$("#parentDiv").empty();
$.getJSON("raw_data.json", ({ Search }) => {
Search.sort((a, b) => a[type] > b[type]);
console.log(`Sorted by: ${type}`);
...code


Different results are shown in different browsers, but the correct one is showing in firefox devoloper edition and wrong results are shown in chrome browser.

Answer

Are you trying it in file:f// or http:// if not http:// try it.and chrome browser does not allow cross domain requests so instead of get you can use getJSON(url,function(){---code---});)
as you mentioned that retrieving data from Omdb api.

Comments