views:

37

answers:

1

I need to close the jquery dialog box and set a session at the same time. Using asp.net and c#.

Whats the best way to do this? Thanks

+1  A: 

I'm not really sure what you're trying to do, but you could just close the dialog and make your $.ajax call right after that, like this:

$("#dialog").dialog("close");
$.ajax({
  type: "GET",
  dataType: "json",
  url: "SessionService.svc/RenewSession",
  success: function(data) { alert("success!"); },
  error: function(m, t, x) { alert("error :: " + m + " - " + t); }
});

If you want the renew session logic to automatically fire when the dialog is closed, you could attach a function to the close event when you initialize the dialog. This way, you won't have to make the $.ajax call when you close the dialog (like in the code above). Here's how you'd do this:

$("#dialog").dialog({
  //some options
  close: RenewSession
});

function RenewSession() {
  $.ajax({
    type: "GET",
    dataType: "json",
    url: "SessionService.svc/RenewSession",
    success: function(data) { alert("success!"); },
    error: function(m, t, x) { alert("error :: " + m + " - " + t); }
  });
}

Let me know if this is what you're trying to do. If not, can you provide some more details in your question and I'll update my answer accordingly. Hope this helps!

David Hoerster