2013-04-08 77 views
-4

什麼是在這種情況下使用AJAX而不是發送形式相當於使用AJAX而不是發送形式

<form action="" method="post"> 
<div style="padding-left: 10 px:"></div> 
<input id ="datetime" style="display:none;" type="text" name="datetime" VALUE="yyyy/MM/dd HH:mm:ss" SIZE="5" > 
<A HREF="#" onClick="cal.select(document.forms[0].datetime,'anchor','MM/dd/yyyy'); return false;"    
    TITLE="cal.select(document.forms['example'].datetime,'anchor','MM/dd/yyyy'); return false;" 
    NAME="anchor" ID="anchor"><i class="icon-calendar"></i> 
</A> 
<input style="font-size: Bold 8pt;" id = "done" type="submit" value="Done" /> 
</form> 

我想使用AJAX後把我的新變量,而不是發送形式。

+0

你爲什麼不讀[**爲$就**文件(HTTP://api.jquery。 com/jQuery.ajax /)並找出? – adeneo 2013-04-08 20:24:47

+0

不知道......我認爲你甚至不知道你在說什麼。 – TechNyquist 2017-05-02 12:43:43

回答

0

這純粹是

$("#done").click(function() { 
    $.post("/",{"datetime": $("#datetime").val()}); 
    return false; 
}) 

更多$.posthttp://api.jquery.com/jQuery.post/

+0

我會把這個到另一個JS文件? 另外,我不需要提交提交輸入嗎? – Talentz 2013-04-08 20:27:35

+0

不,請確保您包含jQuery並將其放在頁面末尾的'

相關問題