Intel xdk不允许我进行Ajax调用

时间:2022-05-12 19:55:01

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:

我有一个PhoneGap项目,我已导入英特尔XDK。 Evetything像以前一样工作,除了我无法处理Ajax调用。阅读文档后,我在所有其他脚本之前添加以下两行:

<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:

我正在使用JQuery $ get来处理Ajax调用。像这样的东西:

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

Can someone please help.

有人可以请帮助。

Regards

问候

1 个解决方案

#1


5  

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:

以下是英特尔XDK中AJAX调用的一个工作示例,您可以在英特尔XDK和设备上试用它,用您的URL替换URL并尝试:

<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>

#1


5  

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:

以下是英特尔XDK中AJAX调用的一个工作示例,您可以在英特尔XDK和设备上试用它,用您的URL替换URL并尝试:

<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>