Я устанавливаю заголовок для вывода в формате xml.
captcha_check.php
<?php
header('Content-Type:text/xml');//needed to output as xml(that is my choice)
echo "<root><message>";
if ($_POST['captcha'] == $_SESSION['captcha'])
echo 'true';
else
echo 'false';
echo "</message></root>";
?>
$("#myForm").submit(function() {
$.ajax({
type: "POST",
url: '/captcha_check.php',
dataType:'xml',
data: captcha_value
success: function(data) {
if($(data).find('message').text() == "true"){
//now you get the true. do whatever you want. even call a function
}
else{
//and false
}
}
});
это мое решение, вероятно, работает и для вас.Я всегда предпочитаю XML для общения.Это мой выбор.