function(){
//alert('gg');
//return true;
var url = "<?php echo(site_url('donations/news_post'.'/'.$news_class_id));?>";
var fun = function(){
$.post
(
url,
$("#testform").serialize(),
function(data){
//alert('teeeeee');
ary= eval("(" + data + ")");
//console.log(ary);
//
arr=ary['news_row']['content'];
$(newstitle).html(ary['news_row']['newstitle']);
$(answer).html(answerxx(arr));//答案
$(newsid).html(newsid_return(ary['news_row']['newsid']));//答案
$(target_all).html(ary['news_row']['target_all']);
if(ary['yesorno'] && ary['yesorno'] == '答案正确')
{
$(jiayisssssssss).show();
}
else
{
$(jiayisssssssss).hide();
}
$(yesorno).html(ary['yesorno']);
//alert(ary['yesorno']);
//alert('POSTID:'+ary['newsidpost']+'----POST ANSWER:'+ary['answerpost']+'----SESSION:'+ary['newsidsession']);
$("input.answerInput").click(fun);
}
);
function answerxx(arr)
{
answer_html='';
for(i=0; i<arr.length; i++)
{
answer_html+='<li><input type="radio" name="answer" value="'+(i+1)+'" class="answerInput" /> '+arr[i]+'</li>';
}
return answer_html;
}
function newsid_return(newsid)
{
newsid_html='<input type="hidden" value="'+newsid+'" name="newsid" />';
return newsid_html;
}
};
$(window).load(fun);
$("p").click(fun);
}
);
服务端php
$data= array();
$data = json_encode($data);
echo($data);