I am trying to insert some Options to select which are taken from DB and are being placed also to a jQuery code. I used json_encode, but that did not fix all the problems.
Basically, the / are escaped and there are only single quotes, which is good, but it places double quote at the start and at the end of the string:
Sample code that I see in console:
"<div style='display: inline-block; width: 30%;'>"+
"Article categories:"+
"<br>"+
"<select name='article_cat' class='textbox' style='width:250px;'>"<option value='1'>Random<\/option>\n"</select>"+
"</div>"+
With this error code in console:
Uncaught SyntaxError: Unexpected identifier
This is the jQuery code in PHP file itself:
var options4 = {
dataType: 'json',
success: function(output) {
$("... BLA BLA BLA .... 40 lines of code....."+
"<div style='display: inline-block; width: 30%;'>"+
"Article categories:"+
"<br>"+
"<select name='article_cat' class='textbox' style='width:250px;'><?php echo json_encode($art_catlist); ?></select>"+
"</div>"+
"Bla bla bla .... another 20 lines of code"+
"</div>").insertBefore("#new_background_header");
Some more jQuery code......
}
Does somebody have idea why that happens?
This code creates the list of options (it has to be usable in PHP too, so cant really change it a lot):
while ($data = dbarray($result)) {
$art_catlist .= "<option value='".$data['article_cat_id']."'>".$data['article_cat_name']."</option>\n";
}
Screen from console:
Ps.: Why you remove Hi at the start of the message? Wanted to say Hi and thanks for every help. Now it seems that I am being rude :(