0

Is it possible to make. jquery ajax success, then continue load page's html?

For explain: I need 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>

3 Answers 3

1

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/

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

Sure there is. <body style="display:none"> $(document).ready(function() { $('body').show(); } (with the JS placed within a script tag of course). I wouldn't really recommend this approach however.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.