[英]how to pass html in json data to from controller to view in codeigniter
I want to pass html in json data.While retrieving the data in view, the html code is also being printed as a string.How can i show a url in json message. 我想在json数据中传递html。在视图中检索数据时,html代码也被打印为字符串。如何在json消息中显示url。
Controller code: 控制器代码:
$jsarr['msg'] = 'you have not yet - register here <a href="member/register">Register</a>';
$jsarr['redirect'] = 0;
echo json_encode($jsarr);
}
In Ajax Success : 在Ajax成功:
if(data.result == 'success'){
//some code
}else{
$(".error").text(data.msg);
}
Got the solution: In jquery,instead of text I used html 得到了解决方案:在jquery中,我使用了html而不是文本
if(data.result == 'success'){
//some code
}else{
$(".error").html(data.msg);
}
Possibly It can be like Controller: 可能它可能像控制器:
$html='<html>
<head>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>';
echo json_encode($html);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.