My server method (void) is called by a javascript function and, int the end, it has to call another page using the Server.Transfer but it isn't happenning, the loaded page still the same (Default). Is a static method.
HttpContext.Current.Server.Transfer("Profile.aspx", true);
could someone help me ?
The JS script is:
function ChamarPerfil(valor) {
jQuery.ajax({
url: 'Default.aspx/ChamaPerfil',
type: "POST",
//data: parametros,
data: JSON.stringify({ 'lat': valor.k, 'lng': valor.A }),
contentType: "application/json; charset=utf-8",
dataType: "json"
});
In a nutshell Server.Transfer
won't work with an ajax call. It is designed to work with a full page, synchronous, postback. When you do a full page postback in asp.net, by default the server retunrs the same "page", Server.Transfer
is used to return a different page.
With your ajax call you will need to redirect using javascript in the success call back using document.location.href="profile.aspx"
If you're redirecting, I'd say you are defeating the purpose of an ajax call anyway and just do it with a full page postback.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.