I am developing a template creation tool that uses a jQuery Ajax request that sends parameters to a PHP file. PHP really creates an HTML template.
function generate() {
$.ajax({
type: "POST",
url: "generate.php",
data: $('#genform :input').serialize(),
dataType: "script",
beforeSend: function() {
$("#loading").html("<img src='images/loadbar.gif' />");
$("#loading")
.dialog({
height: 80,
width: 256,
autoOpen: true,
modal: true
});
},
success: function(data) {
$("#loading").dialog('close');
}
});
}
My problem is that I have ajax dataType: set to "script". Using this, the PHP file generates some jQuery dialogs for any errors that work well. However, after I create the HTML, I am unable to pass it.
So, I probably have 100 lines of generated HTML and javascript that I would like to work with. In a PHP file, I tried:
echo('$("#result").html("'.$html.'");');
, $html . , Chrome "gen.html: 1 Uncaught SyntaxError: ILLEGAL". , , .
, , $html , :
$html = "<div>hi there</div>";
( - ). :
$html = "<div>
hi there
</div>";
.
, , . , HTML-.
PHP, , HTML-.