1
當使用GET
方法提交表單時,我正在重新加載頁面的一部分。下面的JavaScript運行,但我不確定如何從窗體中獲取提交的URL?通過jQuery/Ajax獲取GET URL
我會想到var link = jQuery(this).attr('GET');
或somethign會返回它,並嘗試URL
等......沒有運氣,但。有任何想法嗎?
jQuery('form').submit(function(e){
e.preventDefault();
var link = jQuery(this).attr('GET'); //Get the href attribute
alert(link);
history.pushState('data', '', link);
jQuery('#search_main_section').fadeTo(300,0.3,function(){
load(link + ' #search_main_section', function(){ jQuery("#loader").hide();
jQuery('#search_main_section').fadeTo(100,1, function(){});
});
});
不要忘記返回FALSE;最後! – silly
@silly,這是preventDefault在OP代碼中的作用。 – epascarello
對,對不起! +1! – silly