简体   繁体   中英

Jquery .load() sends POST parameters only once per page load

I have this script:

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

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

});

And this html:

 <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>

I want to send POST variables and retrieve remote page every click, but now it sends POST variables on only first click, after that i must refresh my page .

did you mean hashchange on javascript? just like this

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());
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM