The code below is returned to an html page in an object using AJAX.
It doesn’t seem to do what It does when I am not echoing it as PHP, which is to sort the DIVS as they are created based on the attribute ‘data-sort’
I know that the function is correct, am I perhaps escaping it incorrectly?
echo "
newdiv = $(\'<div id=\'eventdiv\' class=\'shadow curved_sml gradient\' data-sort=\'".$row_display['TimeStamp']."\'>".$row_new['Title']." TIME: ".$row_display['TimeStamp']."</div>\');
div_id_after = Math.floor(parseFloat(newdiv.attr('data-sort')));
$('div[data-sort='+div_id_after+']').after(newdiv);
";
Regards,
Taylor
Yes, you are escaping it incorrectly. What you have is:
but you have incorrect quotes in the third level – HTML passed as string in JS, which in turn is passed as string in PHP. Also you should not escape
'‘s, because you enclosed them in"‘s.Try the following:
I think this should solve your problem. But I did not test it.