我正在使用PHP發送AJAX請求。在表單方法中我使用下面的代碼。無法發送PHP上的AJAX請求
rohit1.php
<form action="index1.php" onsubmit="callfunc()">
<span id="raj"></span>
<input type="submit" value="submit"></div>
</FORM>
在javascript I M使用: callfun.js
function callfunc()
{
var http =new XMLHttpRequest();
var name=prompt('enter name of the form');
var name="rohit";
var url = "index1.php";
var s = document.getElementById('raj').innerHTML;
alert(http);
http.open("POST", "index1.php?name="+name, true);
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
}
}
http.send();
}
當我使用該功能。然後提交這是重定向在index.php?label =而不是index.php?name =我該怎麼做這個?
只是試圖重定向到新的一頁。或者你想要做一些其他 – Rab 2012-07-12 07:21:16
window.location.href =「index1.php?name =」+ name;將爲你工作然後 – Rab 2012-07-12 07:28:01