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();
    });
});
jwchang
  • 10,584
  • 15
  • 58
  • 89
X-men
  • 69
  • 1
  • 5

4 Answers4

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?

Community
  • 1
  • 1
iLaYa ツ
  • 3,941
  • 3
  • 32
  • 48
1

you can use this..

window.location.href = "http://www.google.com";
jeeva
  • 1,573
  • 2
  • 15
  • 24
0

you can try

 <script>
 function name(){
    window.location ='abc.php';
 }
 </script>
Spudley
  • 166,037
  • 39
  • 233
  • 307
zed Blackbeard
  • 760
  • 12
  • 30
-2

you can by breaking into php code inside your javascript

$(document).ready(function()
{

    <?php 
       someFunction();
    ?>
});

but only if your javascript is in a php file so it can be processed by php. So if your linking to a .js file that needs to be changed to .php

Chen Luu
  • 1
  • 1