【问题标题】:Secure mobile apps connection to server安全的移动应用程序连接到服务器
【发布时间】:2020-04-07 15:44:04
【问题描述】:

我正在使用 Java Script 等 Web 技术创建一个移动应用程序。我的服务器正在运行 php 以连接到数据库。如果我想在数据库中插入/删除/更新某些内容,则需要通过 Ajax 传递信息。我知道在使用该应用程序时没有人可以看到源代码,但是如果有人可以通过某种方式获得源代码,我该如何防止用户看到我的服务器地址和php文件名?

示例代码(来自 w3schools):

var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    document.getElementById("txtHint").innerHTML = this.responseText;
  }
};
xmlhttp.open("GET", "gethint.php?q=" + str, true);
xmlhttp.send();

【问题讨论】:

    标签: javascript php ajax web mobile


    【解决方案1】:

    我找到了方法

        <div id="testeFuncao">
            <script type="text/javascript">
                $("#butaoTeste").on("click", function(){
                    var xmlhttp = new XMLHttpRequest();
                    xmlhttp.onreadystatechange = function() {
                    if (this.readyState == 4 && this.status == 200) {
                        document.getElementById("txtHint").innerHTML = this.responseText;
                    }
                    };
                    xmlhttp.open("GET", "gethint.php?q=" + str, true);
                    xmlhttp.send();
                });
    
                $("#testeFuncao").remove();
            </script>
        </div>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-25
      • 1970-01-01
      • 2014-03-20
      • 1970-01-01
      相关资源
      最近更新 更多