0

私はphpでajaxリクエストを送信しています。フォーム メソッドでは、次のコードを使用します。

rohit1.php

<form action="index1.php" onsubmit="callfunc()">
<span id="raj"></span>
<input type="submit" value="submit"></div>

</FORM>

javascript im使用: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?name= の代わりに index.php?label= にリダイレクトされます。これにはどうすればよいですか???

4

2 に答える 2

0

return false関数の最後に追加してみてくださいcallfunc()。フォームのデフォルト イベントを防止し、標準フォームとして機能しません。

于 2012-07-12T07:14:21.553 に答える
0
<form action="index1.php" onsubmit="callfunc()">
    <span id="raj"></span>
    <input type="submit" value="submit"></div>
</form>

適切な JavaScript は次のようになります。

function callfunc() {
    var name = "some name here"; // get this name from whereever you want
    window.location.href = "index1.php?name="+name;
    return false;
}

これはあなたのために働くはずです

于 2012-07-12T07:36:39.303 に答える