Redirecting to another page not working in jquery? [closed]
I am using jquery 1.6.2
and this is my ajax call function:
function remoteCall(sUrl, sQueryStr)
{
$.ajax({
type: "POST",
url: sUrl,
data: sQueryStr,
async: false,
success: function(response){
var obj = $.parseJSON(response);
if( obj.status === "N" ){
alert('You have already submitted the Form');
window.location= 'www.example.com';
}
if( obj.status === "S" || obj.status === "Y"){
alert('Thank you for sumbitting the For开发者_Python百科m');
window.location= 'www.abc.com';
}
}
This window.location
is not working?
Also when in following code window.location
is working in IE and FF but not in Chrome:
function remoteCall1(sUrl, sQueryStr,div)
{
$.post(sUrl, sQueryStr ,
function(response){
if(div !=''){
$('#'+div).html(unescape(response));
return true;
}else{
window.location= "www.google.com";
}
});
}
});
// return URL_Redirect;
}
please help. thanks
Try with
window.location.href = "http://www.google.com";
Also, as Pekka noted, be sure that this is the part that's not really working. Use your JS console to check wheter the statement gets run or not.
remove the "window."
location= "www.google.com";
精彩评论