确保移动应用程序与服务器的连接安全



我正在使用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();

我找到了的方法

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

最新更新