Riha Bohra Ответов: 1

Вставка данных через веб-метод не показывает сообщение данные добавлены успешно


  var data = { name: name, state: state, city: city, add: add, phone: phone };   
     var stringData = JSON.stringify(data);    
            $.ajax({    
                type: "POST",    
                url: "Customer.aspx/insertion",    
                data: stringData,  
              //  data: '{name:"' + name + '", state:"' + state + '",city:"' + city + '",add:"'+add+'"phone:"' +phone+'"  }',
                contentType: "application/json; charset=utf-8",    
                dataType: "json",    
                success: OnSucces,    
                error: OnError    
    });
  
    function OnSucces(response) {
      //  alert("Hello");
        if (response == true) {    
                        alert('Category Added Successfully !!!');    
                        reset();    
                    }    
                    else {    
                        alert(response);    
                    }    
                }    
                function OnError(response) {    
                    alert(response);    
                                    }    
             });  
        
    



What I have tried:

It added data in database  but it not showing message that Data Submitted successfully it tried this code web method  in c#

Christian Graus

Если вы получаете ошибку, почему бы не сказать нам, что это такое?

1 Ответов

Рейтинг:
2

SRL Diagnostic

var data = {
  name: name,
  state: state,
  city: city,
  add: add,
  phone: phone
};
var stringData = JSON.stringify(data);

$.ajax({
  type: "POST",
  url: "Customer.aspx/insertion",
  data: stringData,
  //  data: '{name:"' + name + '", state:"' + state + '",city:"' + city + '",add:"'+add+'"phone:"' +phone+'"  }',
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: OnSucces,
  error: OnError
});

function OnSucces(response) {
  //  alert("Hello");
  if (response == true) {
    alert('Category Added Successfully !!!');
    reset();
  } else {
    alert(response);
  }
}

function OnError(response) {
  alert(response);
}
});