[英]Ajax To PHP converter get value from ajax
我需要幫助,這是我的代碼:
<html>
<head>
<script>
function showHint(str) {
if (str.length == 0) {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("txtHint").innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "getstok.php?secretkey=123&sku=" + str, true);
xmlhttp.send();
}
}
</script>
</head>
<body>
<p><b>Masukkan kode barang / SKU:</b></p>
<form>
Kode Barang: <input type="text" onkeyup="showHint(this.value)">
</form>
<div id="txtHint"></span>
</body>
</html>
我需要的是:
我想隱藏此"secretkey=123"
因此訪客看不到我的秘密鑰匙
當調用"xmlhttp.send();"
返回值,我想像示例一樣將其轉換為php
$getxmlhttp = xmlhttp.send();
當我鍵入某些內容時,它將被稱為調用函數,但是當我按Enter鍵時,如何禁用該輸入或對我來說最好的建議是什么。
例如輸入"YI 067"
1:你不能。 瀏覽器(因此訪問者)始終可以知道使用wich URL和參數調用了wich頁面
2:你不能那樣做。 您需要使用超級全局變量$_GET['your var']
將請求的值獲取到getstok.php
3:正在重新加載頁面,因為它正在發送表單。 默認情況下,它將發送到同一頁面。 只需刪除您的<form>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.