I have a jQuery modal dialog with an iFrame in it that shows some content. When the user selects a parameter in iFrame, I make an Ajax call and then I want to close my dialog box, however it does not close for me.
In my parent form, I have a div tag:
div id="structureDialog" title="Add Structure"
I open my dialog when a user clicks on a parent element:
// bind an onclick event onto tiles to display the modal dialogue window $(".stationTile").bind('click', function () { var src = "<iframe src="myurl" />"; var locationID = 1; $("#structureDialog").attr("locationID", locationID); $("#structureDialog").html(src); //iframe $("#structureDialog").dialog({ modal: true, }); });
In my iFrame, I have the following:
$(".userOption").bind('click', function () { $.ajax({ async: false, type: "POST", url: "/NewStructure.aspx/Build", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: buildSuccess }); }); function buildSuccess(res, dest) { $("body", window.parent.document).attr("style", "background-color:yellow;"); $("#structureDialog", window.parent.document).attr("style", "background-color:red;"); $("#structureDialog", window.parent.document).dialog('close'); }
In my buildSuccess function, I can successfully change my dialog box to red. However, the close function does not close my dialog box. From most of the examples I've seen so far, this code should work fine, so I'm at a dead end.