ndlli 发表于 2017-3-22 11:30:23

jquery ajax php 数据交互

PHP 程序: 
  


public function checkUsername()
{
$username = $_POST['username'];
$this->ajaxReturn($username, '用户名已经存在');
}
 jquery代码:  


var username = $(this).val();
$.ajax({
type: 'post',
url: 'index.php/public/checkUsername',
data: 'username=' + username,
beforeSend: function() {
//alert('beforesend');
},
success: function(msg){
alert(msg);
}
});
  问题: 这样写,不知道数据是否已经传到服务器端了,也不知道是否有数据返回,我初学jquery, 请大侠们指点!
页: [1]
查看完整版本: jquery ajax php 数据交互