如果您AJAX
腳本是一個PHP文件,那麼你可以使用替換的網址0
例如:
file_name.php
$.ajax({
type: 'post',
url: '<?php echo $your_url_var; ?>',
data: {
username:username,
email:email,
mobile:mobile,
uid:uid,
},
success: function (response) {
console.log(response);
alert(response);
if(response == 1){
$('#err_msg').html('<p style="color:green">Form updated successfully!!!</p>');
}else{
$('#err_msg').html('<p style="color:red">Failed. Please try again</p>');
}
},
error:function(error){
alert("error "+ error);
$('#loader-image').hide();
}
});
});
如果AJAX
不在PHP
文件,那麼你需要使用不同的方法。
一個簡單的方法可以使用另一個AJAX
調用或Java-script
條件來確定您的URL。
例如
var your_url = 'update_value.php';
if(something)
your_url = 'new_file.php';
$.ajax({
type: 'post',
url: your_url,
data: {
username:username,
email:email,
mobile:mobile,
uid:uid,
},
success: function (response) {
console.log(response);
alert(response);
if(response == 1){
$('#err_msg').html('<p style="color:green">Form updated successfully!!!</p>');
}else{
$('#err_msg').html('<p style="color:red">Failed. Please try again</p>');
}
},
error:function(error){
alert("error "+ error);
$('#loader-image').hide();
}
});
});
你的問題不明確?你想在Ajax調用成功後將用戶重定向到其他的PHP頁面? – Star
而不是在'#err_msg'中設置成功/錯誤消息,爲什麼不創建兩個不同的被隱藏的元素以及只需要添加文本的樣式。 – Script47
正如你可以看到在Ajax中的網址指向另一頁。我只想將該頁面嵌入到同一個update.php中。可能嗎? –