jquery ajax process success then continue load html code
Is it possible to make. jquery ajax success, then continue load page's html?
For explain: I ne开发者_如何学Pythoned when open the page. fist loading css, js
code. then loading near the jquery ajax code, make a stop. stay the jquery ajax data poccess finished, then continue loading the <body>
code. show <div id="data"></div>
and other html
code.
<script type="text/javascript">
$.ajax({
url: "pageb.php",
dataType: "html",
type: 'POST',
data: "value="+ value,
success: function(data){
//stop open page, after data back success, then continue loading the html code.
$("#data").html(data);
}
});
</script>
</head>
<body>
<div id="data"></div>
...
</body>
If you want that way , you should go for async:false as others suggested.
But async:false will block the page , but if you want that way its fine.
But if you have time try this plugin , nice one
http://jquery.malsup.com/block/
Unless the whole page is loaded via AJAX, there is no way to tell the browser "Ehi, wait rendeering the page until I say so".
Well the idea of AJAX is that it's asynchronous so it does not care about what everything else on the page is doing/what is being loaded, etc. Try setting async:false
in your $.ajax()
params and see what happens.
精彩评论