Validating ajax search

Is there a way to prevent user from entering script tag to the form? Yes, escaping. It is one of the fundamental cornerstones of web security, and completely missing from the code in the question. Take this example: <a href=”<?php echo $foo; ?>”> How do we know it’s actually a URL? Your colleague has said … Read more

wp_post not working, keeps redirecting to posts page

Because you want to run JS code, using WordPress post action handler will not give you the solution. You will need to use ajax for that. I have created a small example you can copy/paste. <form method=”post” class=”myform”> <input type=”hidden” name=”action” value=”add_foobar”> <input type=”hidden” name=”data” value=”foobarid”> <input type=”submit” value=”Submit”> </form> For our form I removed … Read more