नीचे एक jQuery स्क्रिप्ट मैं पर काम कर रहा हूँ है, मैं यह सब के गैर प्रासंगिक भागों नीचे छीन लिया है।क्या आप jquery में किसी अन्य AJAX कॉल के अंदर AJAX कॉल कर सकते हैं?
आप देख सकते हैं कि एक अजाक्स कॉल है, परिणाम अगर कोई कथन है, तो हमारे द्वारा छीनने वाले अन्य सामान, लेकिन पहले एजेक्स कॉल के परिणामस्वरूप कैप्चा को चुना जाता है।
मैं तो एक दूसरे ajax कॉल करने के लिए की जरूरत है, इस जहाँ मेरे मुसीबत है, मैं कोई त्रुटि प्राप्त लेकिन यह एक दूसरे पर एक प्रतिक्रिया वापस जाने के लिए प्रतीत नहीं होता है, मैं कुछ याद आ रही है?
<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>
क्या आपने "त्रुटि" कॉलबैक फ़ंक्शन को फँसाने का प्रयास किया है? त्रुटि: फ़ंक्शन (एक्सएचआर, टेक्स्टस्टैटस) {console.log (XHR); }? फायरबग के अनुरोध पर peeked? – gnarf
यह वास्तव में * अंदर * AJAX कॉल नहीं है, 'सफलता' फ़ंक्शन * कॉल के बाद * है। – Kobi