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>

解决方案 »

  1.   

    将数组用json_encode函数,转换后就是js所需要的json格式了
      

  2.   

    1、用json_encode
    2、success,error自动识别是否ajax提交,如果是自动返回对应的json数据
      

  3.   

    那个success怎么写,我没写function  我是新手,麻烦把具体代码写下!
      

  4.   

    我是返回到一个叫做bussiness.php的页面中,就我贴的代码里面的那个js中
      

  5.   

    见你有 
    $.post("Publication.php",{message:message},
    function(s){
    if(s.status){
    $('#guanzhu').fadeIn();
    }else{
    alert('发表失败');
    }
    },"json")
    }那么 Publication.php 至少得返回一个有名为 status 属性的 json 
    echo '{"status":".$a.'"}';
    中 $a 的取值为 1 或 0
    所以接收到的 json 为 {"status":"1"} 或 {"status":"0"}
    有什么不对吗?
      

  6.   

    我知道要返回一个为status的数据,但是用输出语句输出,我前台js怎么接收不到输出的status数据
      

  7.   

    本帖最后由 xuzuning 于 2012-12-06 13:27:32 编辑
      

  8.   

    本帖最后由 xuzuning 于 2012-12-06 14:48:22 编辑
      

  9.   

    ajax页   echo json_encode($var);