0
我正在嘗試做一個ajax請求。 現在,當我點擊表單中的選項時,沒有發出Ajax請求。但是我去了正確的頁面。jquery幫助製作ajax請求
我的Jquery:
$(document).ready(function() {
// send form ved klik paa listen
$('option').click(function()
{
var form=$(this).closest('form');
$.ajax({
type:'post',
url:form.attr('action'),
data:form.serialize(),
success:function(msg){
$('#formcontent').html(msg);
}
});
});
});
$().ready(function() {
$('#jump_nav_submit').hide();
});
$('#jump_nav').live('change', function() {
window.location = "\/finder\/" + $(this).val();
});
我如何做Ajax請求,從而使得與ID formcontent div和URL是取景器/ whateverthevalueofthe選項。
我試圖刪除此:
$().ready(function() {
$('#jump_nav_submit').hide();
});
$('#jump_nav').live('change', function() {
window.location = "\/finder\/" + $(this).val();
});
但是Ajax請求不能正常工作,因爲該參數是: http://localhost:3000/finder/?id=16&utf8=%E2%9C%93
相反的:http://localhost:3000/finder/1
我想動作網址爲:「\/finder \ /」+ $(this).val(); 而不是form.attr('action')。當用戶點擊一個選項時,requestet頁面應該在formcontent div中呈現,並且ajax url應該是/ finder /選項的值 –