Wednesday 31 May 2017

jQuery Post With and Without Json Response


1.    jQuery Post Method Without json Response


var post_data = 'operation=add&name=Rahul&email=rahul@gmail.com';
jQuery.post('/admin/ajax/do.php', post_data, function(response){
    if(response.msg=="success"){
        alert("Insert Successfully");
    }else{
        alert("Error Occured");
    }
});



2.    jQuery Post Method With json Response


var post_data = 'operation=add&name=Rahul&email=rahul@gmail.com';
jQuery.post('/admin/ajax/do.php', post_data, function(response){
    if(response.msg=="success"){
        alert("Insert Successfully");
    }else{
        alert("Error Occured");
    }
},'json');
banner
Previous Post
Next Post

0 comments: