AnR
AnR

Reputation: 2225

Intel xdk doesn't let me make Ajax calls

I had a PhoneGap project which I have imported into Intel XDK. Evetything is working as before except that I am unable to process Ajax calls. After reading the documentation I add the following two lines before all other scripts:

<script src="intelxdk.js"></script>
<script src="xhr.js"></script>

But that still doesn't have any impact.

I am using jQuery $get to process Ajax Calls. Something like this:

$.get( MyURL, function( data ) {
    alert(data);
}

Upvotes: 2

Views: 5953

Answers (1)

krisrak
krisrak

Reputation: 12952

Here is a working example of AJAX call in Intel XDK, you can try it in Intel XDK and on device, replace the URL with yours and try:

<html>
<head>
    <title>AJAX and XDK</title>
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0;" />
    <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>  
    <script src="intelxdk.js"></script>
    <script src="xhr.js"></script>
    <script>
        function doAJAX() {
            $.ajax({
                type:'GET',
                url:'http://time.jsontest.com/',
                success: function (data) {
                    alert(JSON.stringify(data))
                }
            });
        }
</script>
<style>
    body {font-family:arial;background-color:white}
</style>    
</head>
<body>         
    <h3>AJAX Call</h3>
    <button onclick="doAJAX()">AJAX Call</button>
</body>
</html>

Upvotes: 5

Related Questions