Getting No 'Access-Control-Allow-Origin' header is present on the requested resource



  • Im developing my senior project . I’m using cordova to develop a mobile application on android. language im useing, html5, js, xml, css, jquery, jquery mobile.

    im getting: XMLHttpRequest cannot load http://thegamesdb.net/api/GetGamesList.php?name=zelda. No ‘Access-Control-Allow-Origin’
    header is present on the requested resource. Origin ’http://localhost:8383’ is therefore not allowed access.

    Note: I cant afford to rent a server to run php code on it

    in html page

    $(document).on(“pagebeforeshow”, “#addGamePageOne”, function (){
    document.getElementById(“gameInfo”).innerHTML="";
    $("#searchGame").click(function(search){
    search.preventDefault();
    document.getElementById(“results”).innerHTML=“searching”;
    xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    searchGame(xmlhttp);
    }
    };
    xmlhttp.open(“GET”, "http://thegamesdb.net/api/GetGamesList.php?name="+$("#gameName").val(), true);
    xmlhttp.send();
    });
    });



  • All of the urls are accessible via browser. So if you paste your generated URL into a browser and dont see anything, either the site is down or youve generated an invalid URL.

    If the browser version works, then something is obviously wrong with your code. Test it using a different URL independent of the gamesdb