![]() |
parse html from jquery ajax return
Hello coders,
I have an jquery form validator, client-side but also an php serverside validator. After the form is validated client-side, it would send an ajax to my submit.php page. If the form isn't validated server-side it would return a div with class 'error'. Here's the code: Ajax: Code:
var datastring = 'username='+ username + '&password=' + password Code:
<div class='error'>Username does not match our conditions</div>Response: alertbox with text: "succesvol signup" alertbox with text: "<div class='error'>Username does not match our conditions</div>" and div 'error_form' contained nothing help! |
The response is returned as a string, rather than an HTML element. Try
Code:
var returnAsHTML = $(data);But if you return just a string rather than '<div>...etc.' then you can just use the string as is rather than extracting it. I would consider returning either 'true' or 'Some error message' and check against the text 'true'. |
| All times are GMT +1. The time now is 11:11 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.