我試着做,做了這個功能callFunction();
試圖使一個函數執行功能
我試圖使用AJAX
一個PHP文件執行JS的功能,因爲我有AJAX responseText
我試着使用
<script type="text/javascript"> callFunction(); </script>
,但它沒有工作,我試着做這樣的事情
function exec(func , arg) {
func(arg); // executes the function
}
,如果這樣的事情是不存在的,我怎麼能說與AJAX功能從一個PHP請求(通過GET方法)
我得到的錯誤,當我嘗試它是
FUNC不是函數
JS AJAX代碼
var emailVal = document.getElementById("email").value;
var passVal = document.getElementById("password").value;
var uVal = document.getElementById("username").value;
var busVar = document.getElementById("businessname").value;
var firstVal = document.getElementById("firstname").value;
var params = "email=" + emailVal + "&password=" + passVal + "&businessname="+busVar + "&username="+uVal+"&firstname="+firstVal;
var url = "business.php";
http = new XMLHttpRequest();
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() { //Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
console.log(http.responseText);
exececc(http.responseText , null);
}
}
http.send(params);
PHP代碼
echo '<script type="text/javascript"> callFunction(); </script>';
你需要更多的指定問題。與我們分享更多的代碼等等,很難說出你想在這裏完成什麼。 –
當然!我目前正在添加代碼 –