I would like to extract the sucess and error that this javascript answers me, how is it done?

0

 
 $(document).ready(function(){   
    $('#idBoton').click( function(){ 
           var order_val =$('#verificacion').val();
           var order_name = $('#name').val();
           var order_cedula = $('#cedula').val();
           var order_mail = $('#mail').val();
           var order_phone = $('#phone').val();
           var order_fax = $('#fax').val();
           var order_dir = $('#dir').val();
           var order_city = $('#city').val();
           var order_cargo = $('#cargo').val();
           var order_description =  $('#description').val();  

           	var miBody={
           		"auth_key": "ffa07465e5af0a0f69d776e3a288dea1",
           		"entity_number" : "4006",
           		"contact_name" :order_name,
           		"contact_phone": order_phone,
           		"description" : order_description,
           		"contact_identification": order_cedula,
           		"contact_email":  order_mail,
           		"contact_phone":  order_phone,
           		"contact_fax": order_fax,
           		"contact_address": order_dir,
           		"city_name":  order_city,
           		"contact_position_name": order_cargo,
           		"description": order_description
              }
             
              console.log(miBody);
           
              fetch('http://181.61.221.52:8119/operative/simplecreateticket/', {
                method: "POST",
                headers: {
                  "Content-Type": "application/json",
                },
                body: JSON.stringify(miBody)
             })
              .then(response => response.json()) // response.json() returns a promise
              .then((response) => {
                if(order_val = true)
                 {
                    console.log("se a guardado con exito", response); //returns the new item along with its ID
                     if (!order_vale.ok)
                       {
                         throw Error(response.statusText);
                       }
                      return order_val;
                 }   
              
                 })

              
              .then(response => alert("ok"+order_val) )
              .catch(error => console.log(error) );
   });

    
});
    
asked by Alexander aguilar 30.07.2018 в 23:50
source

0 answers