通过Web方法插入数据,但未成功添加消息数据 [英] Inserting data through web method not showing message data added successfully
本文介绍了通过Web方法插入数据,但未成功添加消息数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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#
推荐答案
.ajax({
类型: POST,
url:Customer.aspx / insertion,
data:stringData,
// data:'{name:'+ name +',state:' + state +',city:'+ city +',添加:'+ add +'phone:'+ phone +'}',
contentType:application / json; charset = utf- 8,
dataType:json,
成功:OnSucces,
错误:OnError
});
函数OnSucces(响应){
// alert(Hello);
if(response == true){
alert('Category added Successfully !!!');
reset();
}
else {
alert(response);
}
}
函数OnError(响应){
alert(response);
}
});
我尝试过:
它在数据库中添加数据但是它没有显示数据已成功提交的消息它在c#中尝试了此代码Web方法
.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#
var data = {
name: name,
state: state,
city: city,
add: add,
phone: phone
};
var stringData = JSON.stringify(data);
.ajax({
type:POST,
url:Customer.aspx /插入,
数据:stringData,
//数据:'{name:'+ name +',state:'+ state +',city:'+ city +' ,添加:'+ add +'phone:'+ phone +'}',
contentType:application / json; charset = utf-8,
dataType:json,
成功:OnSucces,
错误:OnError
});
函数OnSucces(响应){
// alert(Hello);
if(response == true){
alert('Category added Successfully !!!');
reset();
} else {
alert(response);
}
}
函数OnError(响应){
alert(response);
}
});
.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); } });
这篇关于通过Web方法插入数据,但未成功添加消息数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文