[英]Passing post value with ajax
我的index.php中有以下代碼:
$('#whois').click(function () {
//console.log("button clicked");
$('#whois_content').html("");
$('#fade').fadeOut('slow', function () {
urlLinkas();
});
});
我想在此腳本中將post值傳遞給test.php,如下所示:
$('#whois').click(function () {
//console.log("button clicked");
$.ajax({
type: "POST",
url: "test.php",
data: info,
success: function(){
//dont know what to write here
}
$('#whois_content').html("");
$('#fade').fadeOut('slow', function () {
urlLinkas();
});
});
然后在test.php $_POST['info']
調用此發布值
也許有人會明白我在說什么。
這樣會更好
$.post("test.php", { info: "Something", moreinfo: "Something Else" })
.done(function(data) {
$('#whois_content').html("");
$('#fade').fadeOut('slow', function () {
urlLinkas();
});
});
這應該可以工作,嘗試一下:
$('#whois').click(function () {
$.ajax({
type: "POST",
url: "test.php",
data: {info: "some info"},
success: function () {
}
$('#whois_content').html("");
$('#fade').fadeOut('slow', function () {
urlLinkas();
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.