Thursday, 15 August 2013

How to go to previous page after ajax success

How to go to previous page after ajax success

I want after Ajax success function I could return to the previous page.
<div id="dialog" title="Complain">
<form id="komenform">
<label>Model :</label>
<input type="text" id="comodel" name="comodel"/>
<label>Komentar :</label>
<textarea id="comment" name="comment" rows="5" cols="20"
></textarea>
<button id="submitcom" type="button"
class="ui-state-default ui-corner-all"><span>Submit
</span></button>
<input name="action" value="inputcom" type="hidden">
</form>
</div>
$("#komenform").validate({
rules:{
comodel:{
required:true
},
comment:{
required:true
}
}
});
$("#submitcom").click(function() {
if($("#komenform").valid()) {
var params=$("#komenform").serialize();
$.ajax({
type:"post",
url:"/QA/process2.php",
data:params,
cache :false,
async :false,
success : function() {
$("#comodel").val("");
$("#comment").val("");
$("#dialog").dialog('close');
history.back();
},
error : function() {
alert("Data failed to input.");
}
});
}
});
But it won't work.

No comments:

Post a Comment