不知何故,这段代码只是空白,并没有真正做任何事情。 甚至不显示任何错误。 那么有人可以帮忙吗?不知何故,这不会告诉我一个提醒或任何错误
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