不知何故,這段代碼只是空白,並沒有真正做任何事情。 甚至不顯示任何錯誤。 那麼有人可以幫忙嗎?不知何故,這不會告訴我一個提醒或任何錯誤
function connectStart(mycon){ //connection start for contacting
return function(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var jsonReturn = JSON.parse(this.responseText);
mycon; //calls the makeAnn() Function
}
};
// mypref() stands for the preference code location for the myphp.php
xmlhttp.open("GET", mypref()+"myphp.php?q="+myvar,true);
xmlhttp.send();
}
}
function makeAnn(){
return function(){
console.log(jsonReturn);
if (jsonReturn !== "NO"){
alert("Announcement Was Posted");
} else {
alert("Error Encoding Data");
}
} //end of return function()
}
function mainFunction(){ //is called by an onclick event
var myvar = "I Shall Return!";
connectStart(makeAnn()); // i used invocation to combine them
}
不知何故,它從不顯示任何實際的投訴或控制檯日誌上的任何內容。 沒有警報或任何。 不寫數據發送到php或數據庫。 沒有什麼真的。 我試過了PHP和HTML,他們都很好。 這只是我的代碼的這一部分,將無法正常工作。
你什麼時候調用'mainFunction()'..?如果這是你的所有代碼,那麼你並沒有調用任何代碼。請格式正確,非常難以閱讀。理想情況下,請創建一個小提琴或類似的,所以我們可以看到這種情況發生。 http://stackoverflow.com/help/how-to-ask –
這裏沒有「php」這裏 –
剛完成編輯 – Arkonsol