2013-09-28 27 views
0

我有這樣的腳本:jQuery的.load()每頁負載發送POST參數只有一次

$('#openBtn').click(function(){ 

     $(".modal-body").load("/show.php?fFuehIFj1L0vS6Hp", {oi: $("#oi").val(), txtid: $("#txtid").val()}, function(result){ 
     $('#myModal').modal({show:true}); 
    }); 

}); 

而且這個網站:

<a href="#" class="btn" id="openBtn">Open modal</a> 

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog"> 
<div class="modal-header"> 
    <button type="button" class="close" data-dismiss="modal">×</button> 
     <h3>Modal header</h3> 
</div> 
<div class="modal-body"> 
    <p>My modal content here…</p> 
</div> 
<div class="modal-footer"> 
    <button class="btn" data-dismiss="modal">Close</button> 
</div> 

我想發送POST變量和遠程檢索每一個頁面點擊,但現在它只在第一次點擊時發送POST變量,之後我必須刷新我的頁面。

+0

出於好奇,爲什麼你還要對DIV在tabIndex?我以前從來沒有見過。 – JRL

+0

'load()'使用'GET',所以它根本不會真的發送'POST'參數? – adeneo

+0

@adaneo,如果數據作爲對象提供,則使用POST方法 – Chris45234325

回答

0

你的意思是在JavaScript的hashchange? 就這樣

site.com/blah#content=1

function hash() 
{ 
var hash = window.location.href; 
hash = split("#", hash); 
hash = hash[1]; // this is hash param 
return hash; 
} 

$(window).on('hashchange', function() { 
$("#page").load("index.php?"+hash()); 
}); 

$(window).ready(function() { 
$("#page").load("index.php?"+hash()); 
});