带有jquery的Ajax - 如何接收我在C#classe中发送的参数 [英] Ajax with jquery - How to receive the parameters that I send in the C# classe

查看:79
本文介绍了带有jquery的Ajax - 如何接收我在C#classe中发送的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何通过c#classe中的ajax发送的参数插入到数据库中,这里是javascript代码:



I wanna know how can I receive the parameter that I send via ajax in the c# classe to insert in the database, here´s the javascript code:

$.ajax({
      type: 'POST',
      url: 'new_circle.aspx/insertCirclePeople',

      data: "code=" + $('#txtcode').val(),
      //dataType:'json',
      statusCode: {
          404: function () {
              alert('Page not found');
          },
          500: function () {
              alert('Server error');
          }
      },
      success: function (data) {

      }
  });

推荐答案

.ajax({
type:' POST'
url:' new_circle.aspx / insertCirclePeople'

data: code = +
.ajax({ type: 'POST', url: 'new_circle.aspx/insertCirclePeople', data: "code=" +


' #txtcode') .val(),
// dataType:'json',
statusCode :{
404 :function(){
alert(' 找不到页面');
},
500 :function(){
alert(' 服务器错误');
}
},
成功:函数(数据){

}
});
('#txtcode').val(), //dataType:'json', statusCode: { 404: function () { alert('Page not found'); }, 500: function () { alert('Server error'); } }, success: function (data) { } });


在MVC中,您可以在您调用的方法中创建参数参数。在直接的ASP.NET中,我将它们放在你调用的URL上并从那里获取
In MVC you can just make the parameters parameters in your method that you call. In straight ASP.NET, I''d put them on the URL you call and get them from there


这篇关于带有jquery的Ajax - 如何接收我在C#classe中发送的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆