I have c开发者_如何学Created a form maker somewhat like Formtorch for codeigniter. The form consists of 6 text boxes that when submitted go to a php file for execution via ajax. Everything works except for my display. This is what I want to display as code and not as executable script. The idea is to simply copy and paste this to quickly make a form.
<p>
<label for="<?php $v1;?>"><?php echo $v1;?></label>
<input type="text" name="<?php $v1;?>" id="<?php $v1;?>" />
<label class="error" id="<?php $v1;?>">This field is required</label>
</p>
As you might expect, when this is returned to the Ajax success script it comes out as labels and input boxes. My ajax display is like this:
success: function(msg){
if(msg){
$('#display').html(msg).show();
}else{
$('#display').text("nothing came back");
}
}
As stated above the ajax submit and display work perfectly except for the format. I have tried < code >, < pre >. If I switch the html in success to text I get an unformated jumble of text. Any ideas? This is on localhost so I cant show you the page
Formtorch http://formtorch.geekhut.org/
Thank you
You have to replace all the < and > characters with <
and >
Everything between <
and >
is interpreted as a HTML tag, you need to escape it to <
and >
respectively, for example using $().text();
.
精彩评论