Below is a jquery script I am working on, I have stripped down all the non-relevant parts of it.
You can see there is an ajax call, from the results there is an if statement, the other items our stripped out but anyways the captcha one is picked from the result of the first ajax call.
I then need to make a second ajax call, this is where my trouble is, I get no errors but it doesn't seem to return a response on the second one, am I missing something?
<script type="text/javascript">
$(document).ready(function() {
// make ajax call
var dataString = 'comment=' + comment;
$.ajax({
type: "POST",
url: "process.php",
data: dataString,
dataType: "json",
success: function(data) {`
//result from 1st ajax call returns "captcha"
if (data.response === 'captcha') {
//a bunch of code is ran
////////////////////////
//then...
$().bind('cbox_closed', function() {
var dataString2 = 'comment=' + comment + '&run=captchagood';
// our nested ajax call
// this is the part that is having trouble =(
$.ajax({
type: "POST",
url: "process.php",
data2: dataString2,
dataType: "json",
success: function(data2) {
if (data2.response === 'captchagood') {
alert('test');
$('div#loader').find('img.load-gif').remove();
$('div#loader').append('<span class="success">Thanks for your comment!</span>');
$('div#loader').hide().fadeIn('slow');
$('span.limit').remove();
$('div#comments').append(data);
$('div#comments div.comment-unapproved:nth-child(1)').hide().slideDown('slow');
$('input#submit-comment').unbind('click').click(function() {
return false;
});
// success append the sanitized-comment to the page
$('#comments').prepend(data.comment);
};
// end captcha status returned
}
});
});
});
return false;
});
</script>