我试着做,做了这个功能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>';
你需要更多的指定问题。与我们分享更多的代码等等,很难说出你想在这里完成什么。 –
当然!我目前正在添加代码 –