javascript - replace/ encode < and > with jquery/ ajax before submitting -
i have next code part of comment form in page.
$.ajax({ type: "post", url: "path/to/script.php", data: $(form).serialize(), success: function(data) { $('#comment_form').fadeout(1000); var url = 'path/to/script.php'; $('#commenti').load(url + ' .comment'); } }); on server side characters < , > stripped need them allow displaying code snippets within <code></code> tags.
is there way jquery convert < < , > > before submitting comments display without stripped characters?
i haven't found client side solution yet, here little php-serverside function. needs it:
function specialchars($special) { $replace = array( '<' => '<', '>' => '>', '&' => '&' ); homecoming strtr($special, $replace); } use function specialchars based on needs.
javascript php jquery ajax
No comments:
Post a Comment