AJAX,英特尔 XDK 不工作

AJAX, intel XDK not working

我刚刚说过使用 XDK,我认为它是一款出色的软件。我想在我的应用程序中使用 PHP 文件并调用 XAMPP 数据库。

我知道我必须使用 jquery/AJAX 通过 PHP 文件进行连接。

我的第一步只是接到 AJAX 电话以使用 JSON。我不断收到诸如访问被拒绝之类的错误,以及本地主机服务器 im 定位的 404s。

我已经在 XDK 中制作了我的 PHP 文件,这样可以吗?或者在使用 XAMPP 时我需要将它们放在我的 htdocs 的其他地方吗?我的问题真的是我不知道我在修什么。我想以我的 Xampp URL :localhost -> 然后文件路径为目标。

我也不知道我的 jquery 是否正常工作。

这是我的 ajax/jquery/index 页面:

<!DOCTYPE html>

<html lang="en">
  <head>
<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
      <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
 <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
   <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css">
 <script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script> 
    <script>
      $(document).ready(function(){
    $("#btn1").click(function(e){
       e.preventDefault(); // prevent the default action of the click
           var fname = $("#name").val();
    $.ajax({

        type:     "GET",
        url: 'http://localhost/nearly/nearly/www/php/test.php;',
        data: {fname: fname},
        dataType: "jsonp",
        jsonp: 'callback',
        jsonpCallback: 'checkname',
        success: function(msg){
           msg=alert("hello");
    }
    });
});
      });

</script>
</head>
<body>

<div data-role="page">
  <div data-role="main" class="ui-content">
    <form method="get"  >
      <label for="name">First name:</label>
      <input id="name" type="text" name="name" id="name">
        <button id="btn1" type="submit">Go</button>
    </form>
  </div>
    <div id="table"></div>
</div>

</body>
</html>

我的 PHP 来处理这个是 test.php :

<?php     
header("Content-Type: application/json");
 $fname = $_GET['firstname'];


         echo $_GET['checkname'] . '(' . "{'fullname' : '".$fname."'}" . ')';

      }
?>

我不是 100% 支持上面的 JSON 我很少使用这种方法,但有人告诉我它最适合移动应用程序。

如果可能的话,如果有人可以就如何使用 Xampp mySQL 设置 XDK 提出一些建议,并让我知道我上面的代码是否 return 任何内容到我的索引页面所以我知道它的工作原理。

我可以使用 "www" 项目中保存的 php 文件吗?绝对找不到关于使用 XDK 设置 XAMPP 的文档。我可以访问网络服务器,所以如果这是唯一的方法,我可以把文件放在那里。我真的花了 2 个漫长的夜晚来解决我的问题 -

非常感谢任何帮助。对于 Xampp 问题,我的项目保存在 XAMPP

的 htdocs 中

您不能在英特尔 XDK 项目中使用 php,英特尔 XDK 用于在 HTML、CSS 和 JavaScript 中编写应用程序。以 JSON 格式传送数据的 php 代码应托管在远程服务器上。您编写的 HTML5 应用程序可以进行 AJAX 调用以获取 JSON 数据并在应用程序中显示。

我有这个工作。由于@TasosAanastasiou,我得到了一些(声明中的)帮助主要是 xampp。

要将 XDK 与 xampp 一起使用,您必须设置一个虚拟服务器(我认为这是正确的术语)。这涉及登录到您的路由器并在端口 80 上进行端口转发。应用程序类型是 HTTP Web 服务器。完成后,您应该能够从浏览器类型 http://your_ip/xammp and get the xampp homepage. Note you can now get this homepage with both 127.0.0.1 (as normal) and with your your_ip. Then in your XDK your Urls in your scripts will use http://your_ip/xampp/path 到 htdocs 中的文件夹。

http://your_ip/path 到 htdocs 中的文件夹。

注意:我遇到了一些问题,我不得不更改我的 apache 配置文件以使用 xampp 新的安全协议......

我在这里再次使用了来自@TasosAanastasiou 的建议的答案

它现在可以完美运行,我的 xdk 可以与 Xampp 和 MySQL

一起使用

我会postlink.

这是聊天中的原始问题,因此未 post 编辑答案 Intel XDK, AJAX and XAMPP mySQL connection

这是阿帕奇 link: Error when trying to access XAMPP from a network

这不是 Tasos 指导我的问题。解决方案是注释掉 "deny from all" 并添加 "allow from all ",如上述问题所述。

此错误发生在端口转发练习之后。如果您正在与 xampp 交谈,您可能会关闭。