php处理ajax怎么返回json数据
php源代码
<?php
session_start();
include_once( 'config.php' );
include_once( 'saetv2.ex.class.php' );
$c = new SaeTClientV2( WB_AKEY , WB_SKEY , $_SESSION['token']['access_token'] );
$message = $_POST['message'];
$weibo = $c-> update($message);
if(!empty($weibo)){
$a = 1;
}else{
$a = 0;
}
html页面
<div id="weibo" style="width:500px;height:500px;border:1px grey solid;">
<div id="right" style = "float:right;border:1px grey solid;width:300px;height:300px;">
<ul>你最萌的企业女仆娘是:<?php echo $needMaid;?></ul>
<ul>你最萌的女仆娘属性是:<?php echo $needProperty;?></ul>
</div>
<div id="right_down"style = "float:right;border:1px grey solid;width:299px;height:195px;">
<textarea name="message" cols="" rows="5"style="width: 294px; height: 130px;"> "#你最萌的企业女仆娘 这个测试好有趣,原来中国知名的互联网公司都被娘化了。测试结果显示我最萌的企业女仆娘是【<?php echo $needMaid;?>】,我最萌的女仆属性为【<?php echo $needProperty;?>】,你也赶紧来测试一下吧。"
</textarea>
<li style="float:left;list-style:none;margin-top:20px;margin-left:20px;"><a href="weibolist.php" style="text-decoration: none;"><input name="" type="button" value="再测一次"style="width:80px;height:31px;"></a>
</li><li style="float:left; list-style:none;margin-left:30px;margin-top:20px;"><a href="javascript:;" onclick="release();"><img src="images/giveweibo.jpg"></a></li>
</div>
</div>
js代码
<script type="text/javascript">
function release(){
var message = $('textarea[name=message]').val();
$.post("Publication.php",{message:message},
function(s){
if(s.status){
$('#guanzhu').fadeIn();
}else{
alert('发表失败');
}
},"json")
}
</script>