php获取return,如何使用PHP中的return获取响应并在jquery中使用它

下面的jquery是检查数据库中的用户名和电子邮件。当我回复false或ture时,jquery的工作原理,但它给PHP错误。所以我只想从PHP代码中返回false或true。但是当我这样做时,jquery不起作用。

我在这里做错了什么?

提前致谢。

jQuery的

$(document).ready(function(){

$("#name").blur(function()

{

var nameval = $(this).val();

if(nameval)

{

...

...

//check the username exists or not from ajax

$.post("<?php echo site_url('welcome/user_availability'); ?>",{ what:$(this).val(), where:"name" } ,function(data)

{

if(data==false) //if username not avaiable

{

$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox

{

//add message and change the class of the box and start fading

$(this).html('This User name Already exists').addClass('messageboxerror').fadeTo(900,1);

});

}

else

{

$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox

{

//add message and change the class of the box and start fading

$(this).html('Username available to register').addClass('messageboxok').fadeTo(900,1);

});

}

});

}

else

{

$("#msgbox").fadeTo(200,0);

}

});

...

...PHP

function user_availability()

{

$module = "subscribers";

$where = $this->input->post('where');

$what = $this->input->post('what');

$customers = $this->MKaimonokago->getAllSimple($module, $where , $what );

if (!empty($customers))

{

//user name is not available

return false; // I want to use return here.

// this works but it gives php error

// echo "false";

}

else

{

return true;

}

}PHP错误

ERROR - 2012-04-11 21:43:06 --> Severity: Warning --> Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/kaimonokago2.0/application/modules/welcome/controllers/welcome.php:1084) /Applications/MAMP/htdocs/kaimonokago2.0/system/core/Output.php 391

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值