furry furry - 1 year ago 78
Javascript Question

Cannot execute get from javascript

I need execute get after timeout so I do

window.setTimeout(function() {
}, 600);

but it does not execute at all
then I do next

window.setTimeout(function() {
}, 600);

It executes and canot find a path which is wrong


so how can i actually make a
after delay?

Answer Source

If the URL you are trying to use $.get() with is this (which I'm just guessing because you haven't been entirely clear about that):


Then, use:

window.setTimeout(function() {
    $.get("/grammar/final.jsp").then(function(result) {
        // process result here
}, 600);

If you're actually trying to retrieve content with that Ajax call, then you will need to do something with the result of the ajax call.

If you're trying to open the URL in the browser (which your question does not actually say), then you don't use $.get() because that's an Ajax call. Instead, you would want to use either this:

// change current window to new URL
window.location = "http://localhost:8080/grammar/final.jsp";

or this:

// open new window (will probably get blocked by pop-up blocker)
// if done from setTimeout()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download