2013-04-18 57 views
0

我有这样的代码在我的index.php:传递岗位价值与阿贾克斯

$('#whois').click(function() { 
     //console.log("button clicked"); 
      $('#whois_content').html(""); 
      $('#fade').fadeOut('slow', function() { 
       urlLinkas(); 
      }); 
     }); 

我想传递一个岗位价值,以这个剧本里面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']

也许有人会明白我在说什么。

+0

的信息变量没有定义是什么? – 2013-04-18 05:41:19

+1

也许你会提出一个问题? P.S .:尝试'var_dump($ _ POST);'。 – BlitZ 2013-04-18 05:41:29

+0

定义'数据类型'并尝试 – dreamweiver 2013-04-18 05:42:31

回答

1

这将是更好的

$.post("test.php", { info: "Something", moreinfo: "Something Else" }) 
.done(function(data) { 
    $('#whois_content').html(""); 
    $('#fade').fadeOut('slow', function() { 
     urlLinkas(); 
    }); 
}); 
0

这应该工作,尝试一下:

$('#whois').click(function() { 
     $.ajax({ 
      type: "POST", 
     url: "test.php", 
     data: {info: "some info"}, 
     success: function() { 

     } 
     $('#whois_content').html(""); 
    $('#fade').fadeOut('slow', function() { 
     urlLinkas(); 
    }); 
});