I have a php file which contains a div element with id= containerbox
.
<div id=containerbox>
<button id="buttonme" type="button">click me</button>
</div>
<script>
$("#buttonme").click(function(){
jQuery.ajax({
type: 'POST',
url: 'testone.php',
success: function (data) {
response = jQuery.parseJSON(data);
if (response.status == 'error') {
erroroccur(response);
}
}
});
})
function erroccur(abc) {
alert(error);
//here i want something that only Refreshes/Reloads the containerbox
}
</script>
testone.php
<?php
//...something
$response=Array(
"status"=>'error'
);
return json_encode($response);
?>
it contains one function which makes an ajax call and depending on the response recieved it decides if it is an error.Whenever it recieves an error in the response it fires a function which need to show an alert box and reset the Div element to the way it was when i first came to that page.Can this be achieved?
Note: I know nothing will change there but just for the sake of simplicity i have used this example