OK.... I hope people will forgive my faux pas of responding to my own item...

so I have found my problem. It turns out that the "this" in the line: $(this).dialog('close');

is not referring to the dialog...  but to the ajax request.  Duh.

There are a couple other things too...  but I was wondering about this:

When I get the return from the ajax request, I want to call another function that calls an ajax request. Seems that things get kinda messed up. I have fixed it by setting a timeout to call that function.

Are embedded Ajax calls not supported?

Thanks.


On Jul 31, 2009, at 1:40 PM, Daniel Israel wrote:


I'm using jQuery and jQueryUI. I'm new to jQuery, so any help much appreciated...

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.

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.

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.

If it matters, I'm on OS X using FF 3.51

Note that if I put an alert before the dialog('close') call, the alert pops up, but the dialog does not close... :(

Code for this dialog is here:

                $("#dialog").dialog({
                        bgiframe: true,
                        autoOpen: false,
                        height: 350,
                        modal: true,
                        buttons: {
                                'Create': function() {
var data = { section: $("#section_id").val(), label: $ ("#label").val(), description: $("#description").val(), thumbnail: $ ("#thumbnail").val(), format: $("#format").val() };
                                        $.post("command/save_section.php", 
data, function(xml) {
                                                var save_request = 
parseInt($("#section_id").val());
                                                var save_result = 
parseInt($('section', xml).text());
                                                //alert("testing " + save_request + 
" to " + save_result);
                                                if (save_request == 
save_result) {
                                                        $(this).dialog('close');
                                                }
                                                else {
open_alert_dialog("There was an error when processing this request!");
                                                }
                                        });
                                },
                                Cancel: function() {
                                        $(this).dialog('close');
                                }
                        },
                        close: function() {
                                allFields.val('').removeClass('ui-state-error');
                        }
                });



any help is appreciated... thanks.


-D. Israel
d...@ebji.org
http://www.customcodebydan.com
AIM: JudoDanIzz

If a dozen smart, successful people who've achieved something great are all giving the same advice, take it.


-D. Israel
d...@ebji.org
http://www.customcodebydan.com
AIM: JudoDanIzz

If a dozen smart, successful people who've achieved something great are all giving the same advice, take it.

Reply via email to