I working on this code...
<script>
$("#ajaxform").submit(function(e)
{
$("#simple-msg").html("<img src='images/ajax-loader.gif'/>");
var postData = $(this).serializeArray();
var formURL = $(this).attr("action");
$.ajax(
{
url : formURL,
type: "POST",
data : postData,
success:function(data, textStatus, jqXHR)
{
$("#simple-msg").html('<pre><code class="prettyprint">'+data+'</code></pre>');
},
error: function(jqXHR, textStatus, errorThrown)
{
$("#simple-msg").html('<pre><code class="prettyprint">AJAX Request Failed<br/> textStatus='+textStatus+', errorThrown='+errorThrown+'</code></pre>');
}
});
e.preventDefault(); //STOP default action
});
$("#ajaxform").submit(); //SUBMIT FORM
$('#simple-post').click(function(){
$('#simple-msg').css({
'display':'block',
'background-color':'red',
'font-size':'44px'
});
});
if the data that return is successful it appear like this :
{
status: "Success",
msg: "You have been registered"
}
and if the data that return is success but registration failed.
{
status: "Fail",
msg: "Please provide full name"
}
how do i redirect user to external website let say www.google.com if only the return status is success in the json ?
=========================================
lol seem to answering my own question....
here how i manage to do it eventually ..
success:function(data, textStatus, jqXHR)
{
var a = JSON.parse(data)
if(a.status == 'success') window.location.href = 'http://google.com';
else
$("#simple-msg").html('<pre><code class="prettyprint">'+a.status+'</code></pre>');
},