keith Spiteri
keith Spiteri

Reputation: 279

Call/load Jquery Page

I have a login screen which the user logs in using Jquery and AJAX. That's fine. Now what I want is that if the user logs in correctly, I want to load another page.

I tried using document.location = "home.html"; but that refreshes my page. What I want is like that transition that normally we have when we click on tag like

<a href="SchoolMaterials.html"> <!-- this does not refresh -->

I don't know if I explained myself clearly.

Thanks

Upvotes: 0

Views: 38

Answers (2)

Mavlarn
Mavlarn

Reputation: 3883

It will be better to load the page in your callback function of successful login with:

$("#the_div_container_for_new_page").load("SchoolMaterials.html")

UPDATED:

it is something like this:

$(document).ready() {
    function login() {
        //post with ajax to login
        $.post(......, function(result){
            if (result.success) {
                // load some page after successful login.
                $('#id_of_container_div').load("thepage.html");
                return;
            } else {
                // handle error
            }
        })
    }
}

Upvotes: 1

zack
zack

Reputation: 1

window.location is just what you need. You can also create an anchor element using jQuery and simulate a click on it :

$("<a href='your url'></a>").click();

But i wouldn't recommend that, it's better to post your data to the server and redirect to the page you want.

Upvotes: 0

Related Questions