试了两天了都没解决!哪位大神可以帮忙解决下,急,在线等!ajax返回的数组为什么alert为undefined?注:readComment.php是确定可以和数据库链接并取到正确的结果数组的,其他方法试过,用了ajax就不行了。。。Ajaxfunction:$('#getComments').click(function(){varrecipe=document.title;varsession_username='<%=session.getAttribute("username")%>';$.ajax({type:'POST',url:"readComment.php",data:{"recipe":recipe},dataType:'json',success:function(data){alert(JSON.stringify(data).username);//alertundefined!},error:function(){alert("error");}});});phpfile:readComment:Makesuretheusercanreadthecomments.*/require_once'./resources/fragments/start.php';useTastyRecipesControllerSessionManager;$recipe=$_POST["recipe"];$controller=SessionManager::getController();$result_array=$controller->getComments($recipe);echojson_encode($result_array);
holdtom
相关分类