Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(".btnSubmit").click(function(){
- form_id = $(this).parent().parent().parent();
- url_target = form_id.attr('action');
- var params = form_id.serialize();
- // console.log(form_id, params);
- var respon = jQuery.ajax({
- url: url_target,
- type: "POST",
- data: params,
- dataType: "json", //disarankan return sebagai JSON.. json_encode($params);
- cache:false,
- timeout:20000
- });
- respon.success(function(result, status) {
- //console.log("OK",result,status);
- //================LAKUKAN PROSES KALAU BENAR.. check nilai result.status
- if (typeof result.status !== 'undefined') {
- if (result.status) {
- //==proses kl OK
- console.log('OK');
- } else {
- //==proses kl GAGAL
- console.log('gagal');
- }
- } else {
- alert('not valid json');
- }
- });
- respon.error(function (xhr, status, msg) {
- //console.log("ERROR",xhr,status,msg);
- //alert(msg);
- //================LAKUKAN PROSES KALAU SALAH
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement