[jQuery] Ajax sometimes not executing callback...
<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>
</div><div>I'm using jQuery and jQueryUI. I'm new to jQuery, so any help much appreciated...</div><div>
</div><div>I have an application where I am displaying a list from a database. When the user hits a button, a modal form dialog comes up and they can enter data.</div><div>
</div><div>It makes an ajax call to the server, gets the data, populates the dialog, then opens it. Change the data, hit the "Create" button and it makes another Ajax call to update the database.</div><div>
</div><div>I see the changes (correctly) in the database, but the callback is not being executed! It's the weirdest thing... I'm not sure what the problem is.. I examine the HTTP traffic and I'm getting a status of 200 and the response looks correct.</div><div>
</div><div>If it matters, I'm on OS X using FF 3.51</div><div>
</div><div>Note that if I put an alert before the dialog('close') call, the alert pops up, but the dialog does not close... :(</div><div>
</div><div>Code for this dialog is here:</div><div>
</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>$("#dialog").dialog({</div><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>bgiframe: true,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>autoOpen: false,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>height: 350,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>modal: true,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>buttons: {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>'Create': function() {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>var data = { section: $("#section_id").val(), label: $("#label").val(), description: $("#description").val(), thumbnail: $("#thumbnail").val(), format: $("#format").val() };</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>$.post("command/save_section.php", data, function(xml) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>var save_request = parseInt($("#section_id").val());</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>var save_result = parseInt($('section', xml).text());</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>//alert("testing " + save_request + " to " + save_result);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if (save_request == save_result) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>$(this).dialog('close');</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>else {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>open_alert_dialog("There was an error when processing this request!");</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>});</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>},</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>Cancel: function() {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>$(this).dialog('close');</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>},</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>close: function() {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>allFields.val('').removeClass('ui-state-error');</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>});</div><div>
</div><div>
</div></div><div>
</div><div>any help is appreciated... thanks.</div><div>
</div>
<div> <span class="Apple-style-span" style="font-size: 14px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="font-family: 'times new roman'; font-size: 16px; ">-D. Israel
<a href="mailto:dan@ebji.org">dan@ebji.org</a>
<span><a target="_blank" href="http://www.customcodebydan.com/">http://www.customcodebydan.com</a></span>
AIM: JudoDanIzz</span></div><div><font class="Apple-style-span" face="'times new roman'" size="4"><span class="Apple-style-span" style="font-size: 16px; ">
</span></font></div><div><font class="Apple-style-span" face="'times new roman'" size="4"><span class="Apple-style-span" style="font-size: 16px; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: 14px; ">If a dozen smart, successful people who've achieved something great are all giving the same advice, take it.</span></span></font></div></div></span></div></span></div></span> </div>
</body></html>