Problem with Modal Dialog jquery and Function Close

Hi, i have a problem with a modal dialog, the close function dont close the modal, i dont know why?  

"btn" is it button that I click.

My code is the next:

    $("#btn").click(function () {
        aRow = jQuery("#BudgetGrid").jqGrid('getGridParam','selrow');
        if (aRow)
            var ret = jQuery("#BudgetGrid").jqGrid('getRowData',aRow);
            var iId = ret.Id;
                autoOpen: false,
                width: 400,
                resizable: false,
                modal: true,
                open: function (event, ui) {

                        url: '/Budget/BudgetUpdate/',
                        type: 'POST',
                        cache: false,
                        loadComplete: function() {
                                        alert("grid is loaded/reloaded");
                        data: { iBudgetId: $("#hdBudgetId").val(), sDescription:$("#DESCRIPTION").val()  },
                        success: function (result) {
                                    if (result!=undefined) {
                                    } else {
                                    jAlert("Data error read!!");
                    $(this).dialog('close');     ///// DONT WORK!!
                    $(this).dialog("destroy").remove()   //// DONT work!!!

        jAlert("Select line to edit!!..")

Regards and thanks for you help! HerediSoft-527956.flv HerediSoft-527956.flv
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michel PlungjanIT ExpertCommented:
Can you create a for it?
HerediSoftAuthor Commented:
Thanks for answer!, basically i need when the modal window show it, my button close created, allow close the modal window no with button "x".



HerediSoftAuthor Commented:
Had that re-code the script in my solution, the project is MVC 3 and jquery and the solution was return a partial view.
Thanks for you help mplungjan. ;)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HerediSoftAuthor Commented:
find the solution in the next url :
Michel PlungjanIT ExpertCommented:
Great you found it
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.