Reload a page with JavaScript (within jquery ajax-request)
my question is, what I have to do to reload a page with javascript. I have written the following function:
function update(id, name)
{
if(/^\d+$/.test(id))
{
$.ajax({
url: baseurl + "/url/action/param/" + id + "/param2/" + unescape(name),
success: function(data) {
$("#overlay").fadeOut().remove();
if(data.status 开发者_如何转开发== '200') {
window.location.reload()
}
else if(data.error) {
$("#messages").html(data.error).fadeIn();
}
},
type: "GET",
dataType: "text"
});
}
else
{
return false;
}
}
The problem is, that the ajax-request is successfull, the result is a json-object:
{"status":"200"}
But the window doesn't reload. If I use the this line
window.location.reload()
at firebug and execute it, the browser window reloads.
What could be the problem? Thanks in advance.
Try changing the data type to JSON:
dataType: "json"
You have a syntax error end of window.location.reload()
. Add semicolon after this line and try again.
精彩评论