In my windows gadget code in made an ajax (POST) call using jQuery in SettingsClosing(event). I watch the ajax call execution through Fiddler. Ajax call is returning the desired results.But it is not triggering success callback ajax. I tried the same code in OnPageLoad() event of main view it is working fine there, My code is like this
function Login(username, password) {
var url = "http://example.com/Auth.php";
var data = { pusername: username, ppassword: password };
jQuery.support.cors = true;
$.ajax({
type: "POST"
, dataType: "json"
, url: url, data: data
, success: function (refresh_token) {
System.Gadget.Settings.write("success", "true");
System.Gadget.Settings.write("dd", refresh_token);
var tok = refresh_token['refreshtoken'];
var name = refresh_token['name'];
System.Gadget.Settings.write("name", name);
System.Gadget.Settings.write("refreshtoken", tok);
}
, error: function (XMLHttpRequest, textStatus, errorThrown) {
System.Gadget.Settings.write("login_error", errorThrown);
System.Gadget.Settings.write("login_STATUS", textStatus);
}
});
}
function SettingsClosing(event)
{
//use this question to now if setting was closed with OK button
if (event.closeAction == event.Action.commit)
{
var username = $('#txtpUsername').val();
var password = $('#txtpPassword').val();
Login(username, password);
}
}
Any help is appreciated.