0

How can I add redirect URL link to JS function (example form action to : session.php) in below code. I've tried with another way code, but it still can't function.

$(document).ready(function() {
    $("#submit_butt").click(function() {
        var conf = {
            frequency: 5000,
            spread: 5,
            duration: 600
        };
        /* do your AJAX call and processing here...
        ....
        ....
        */
        // this is the call we make when the AJAX callback function indicates a login failure 
        $("#login").vibrate(conf);

        // let's also display a notification
        if($("#errormsg").text() == "")
            $("#loginform").append('<p id="errormsg">Invalid username or password!</p>');       

        // clear the fields to discourage brute forcing :)
        $("#password").val("");
        document.forms['login_form'].elements['username'].focus();
    });
});
3
  • 1
    php works on a server, js works on a client. You cannot add php function to js code. Commented Sep 7, 2012 at 3:28
  • Sorry, I mean how to add redirect url into JS function. I've edited my post. Sorry Commented Sep 7, 2012 at 3:32
  • 2
    window.location.replace('http://google.com'); --- this is how you redirect in js Commented Sep 7, 2012 at 3:32

3 Answers 3

2

You can try this

// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");

// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";

https://developer.mozilla.org/en-US/docs/DOM/window.location

Ref: How to redirect to another webpage in JavaScript/jQuery?

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

3 Comments

Did you just take another person's answer as is? stackoverflow.com/a/506004/251311
@LearneR: well, if you use another's answer - then it makes sense to give an original reference, otherwise it looks like a theft
@zerkms: okay it wont happen again. Added the reference link.
1

you can use this..

window.location.href = "http://www.google.com";

Comments

0

you can try

 <script>
 function name(){
    window.location ='abc.php';
 }
 </script>

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.