2013-05-31 25 views
0

我有以下形式:如何設置表單中的變量以便在AJAX調用中使用?

<form action="test.php" method="POST" onsubmit="loadXMLDoc(this.form); return false;"> 
    <input class="com" type="text" name="test" /> 
    </form> 

而是「this.form」的,你會需要在自己的位置,這樣由用戶輸入的文本傳遞給loadXMLDoc?

另外:是否正確的語法,然後發送這個變量數據?

function loadXMLDoc($testVariable) 

//standard ajax code.. 

xmlhttp.send("test=" + $testVariable); 

回答

1

表單可以按名稱引用輸入元素作爲屬性。

loadXMLDoc(this.test.value); 
相關問題