look at this script please
$("#change").click(function()
{
var val = $("#new_title").val();
if(val == '')
{
alert("Նշեք խնդրեմ անունը");
return false;
}
else
{
$.post
(
"change_title.php",
{id: id, lang: lang, val: val}
);
window.location.reload();
}
});
where id
and lang
are global variables.
in change_title.php i'm uploading the table.
i want to show changes after editing, so i use window.location.reload();
function, but it doesn't work. if i delete window.location.reload();
function, it works fine.
what is the problem?
Thanks
You need to run it after the $.post()
completes, like this:
$.post("change_title.php",
{id: id, lang: lang, val: val},
function() {window.location.reload(); });
Without doing this as the callback to $.post()
(this runs when it completes), the window is leaving the page before the POST completes. If you don't need to do anything else in that function, you can shorten it down to:
$.post("change_title.php",
{id: id, lang: lang, val: val},
window.location.reload);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With