How to use native javascript write jquery $.getJSON function?
A demo i only want to use jquery $.getJSON function,but now i must import jquery, so i want to use native javascript write jquery $.getJSON function. My Code is: var $={ getJSON: function(url, params, callback){ var reqUrl = url; var xhr = new XMLHttpRequest; xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { JSON.parse(xhr.responseText); } } xhr.open("GET", reqUrl); xhr.send(); } }; use chrome show: XMLHttpRequest cannot load xxxx Origin xx is not allowed by Access-Control-Allow-Origin. who can help me? Make an ajax request and use JSON.parse on the result.