php - why do we need to place the source name to redirect? -
i saw in post (jquery ajax php redirecting page) when using ajax redirect php page need set event :
$.ajax({ type: "post", url: "ajax.php", data: datastring, success: function(r) { window.location = 'new.php';//window.location.href = 'new.php'; //$("#div").html(r); }, });
however it's not clear me :
- why need indicate " url: "ajax.php","
- should url entry contain name of current file we're redirecting ?
- if i'm redirecting file called abc.html ? should replace ajax.php abc.html ?
thanks!
let me explain
$.ajax({ type: "post", url: "ajax.php", data: datastring, success: function(r) { window.location = 'new.php';//window.location.href = 'new.php'; //$("#div").html(r); }, });
$.ajax function makes ajax request files ..
your questions
- why need indicate " url: "ajax.php","
- should url entry contain name of current file we're redirecting ?
- if i'm redirecting file called abc.html ? should replace ajax.php abc.html ?
answer #1
this line means url: ajax.php ... want make ajax request in case code making ajax request file ajax.php
answer #2
no totally separate redirecting ..
answer #3
no if change ajax.php abc.html not redirect..after changing make ajax request abc.html now
and redirecting ... use simple code
window.location.href = 'filename'; // replace filename file new.php
Comments
Post a Comment