2013-06-24 33 views
-1

如何使用javascript/greasemonkey正確提交此表單?如何使用javascript/greasemonkey正確提交此表單?

<form action="/user/cart/add/66004574/93973071" method="POST"> 
<button class="text" value="upvote" type="submit"> 
<i class="icon-plus"></i> 
Add to Cart 
</button> 
<input type="hidden" value="1337250c-b697-4e0e-b8fa-56bdedc8cd6a" name="_csrf_token"> 
</form> 
+1

你有什麼特別的困難? – bfuoco

回答

0

使用jQuery你可以提交此表是這樣的:

在此功能,您可以處理表單的數據。

$(document).on("submit", "form", function(e){ 
    e.preventDefault(); 

    // get the data of the form 
    var url = $(this).attr("action"), 
     _csrf_token = $(this).find("input name=['_csrf_token']).val(); 

    // jquery ajax call for example 
    $.ajax(

    ); 
}); 
+0

Thx,但沒有提交表單,沒有任何反應。 – user2518009

+0

你必須完成$ .ajax調用,否則什麼都不會發生。嘗試在'e.preventDefault();'之後添加'alert(「Form submitted」);'' –