2011-03-21 81 views
3

我想在colobox jquery上显示我的html内容。 这里im使用ajax函数来提交我的数据,但在成功函数中返回一些html页面。现在我想在colorbox上显示我的html内容。 我怎么能做到这一点.. 我的代码是这样的:如何在colorbox上显示html内容jquery

$('#submitButtonName').click(function(event) { 
    event.preventDefault(); 
    alert("press"); 
    var send=$("#ajaxadd").serialize(); 
    alert(send); 
    $.ajax({ 
    type:"POST", 
    url:"/patient_add", 
    data:send, 
    success: function(msg) { 
     $("#gg").html(msg);// here gg is the id which im try to retrieve from my html page. not getting exactly. 
     alert(msg); 
    //$(".display").colorbox({html:'<p>Hello</p>'}); 
    } 
}); 
$(".display").colorbox({html:send}); 

,这里是我的html文件。我希望我的患者姓名,uhid,年龄显示在colorbox上。

<body> 
<div id="gg"> 
<form id="FormName11" action="/display" method="post" name="FormName11"> 
<table> 
<tr><div align="center"><h2><b><u>Fortis-Medremind Patient Receipt</u></b><h2></div></tr> 
</table> 
<table> 

<b>PatientName</b>: {{patientinfo_all.name}} 
<br> 
<b>UHid</b>   : {{patientinfo_all.uhid}} 
<br> 
<b>Age</b>   : {{patientinfo_all.age}} 
<br> 

</form> 
</div> 

感谢名单提前..

回答

5

一种方式是通过textarea的标签括起来。

例如

var response = '<textarea style="width:688px; height:458px">' + data + '</textarea>'; 
$.colorbox({title:'Response',width:'700px',height:'500px',html:response});