ajax发布内部服务器错误 [英] ajax post internal server error

查看:94
本文介绍了ajax发布内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




i在单独的js文件中使用ajax帖子



Hi
i use ajax post in separate js file as

$.ajax({
   type: "POST",
   contentType: "application/json; charset=utf-8",
   //url: "hotels.aspx/BindDatatable",
   url: '@Url.Action("hotels.aspx","BindDatatable")',
   /*data: "{}",*/
   data: "{'ToValue':'"+totval+"',"+"'checkin':'"+chkin+"',checkout:'"+ckhout+"'}",
   /*data:{ToValue:totval,checkin:chkin,checkout:ckhout},*/
   dataType: "json",
   success: function(data) {
      var theHtml = data.d;
      //  alert(data.d);
      window.location.href = data.d;
   },
   error: function(xhr, textStatus, errorThrown) {
      //alert("Error is " + result.value);
      alert("FAIL: " + xhr + " " + textStatus + " " + errorThrown);
   }
});





但收到错误



内部服务器错误



什么是错误。

i传递来自WebMEthod的参数,这些参数位于数据{}中ajax post



和asp.net hotels.aspx页面,我使用WebMethod



请咨询



but get error as

internal server error

what is error.
i pass parameters in WebMEthod from here , which are in data{} in ajax post

and in asp.net hotels.aspx page , i use WebMethod

pls advice

推荐答案

.ajax({
type: POST
contentType: application / json; charset = utf-8
// url:hotels.aspx / BindDatatable,
url:' @ Url.Action(hotels.aspx,BindDatatable)'
/ * data:{},* /
data:< span class =code-string> {'ToValue':' + totval + ', + 'checkin':' + chkin + ',checkout:' + ckhout + '}
/ * data:{ToValue:totval,checkin: chkin,checkout:ckhout},* /
dataType: json
成功: function (数据){
var theHtml = data.d ;
// alert(data.d);
window location .href = data.d;
},
错误: function (xhr,textStatus,errorThrown){
/ / alert(错误是+ result.value);
alert( FAIL: + xhr + + textStatus + + errorThrown);
}
});
.ajax({ type: "POST", contentType: "application/json; charset=utf-8", //url: "hotels.aspx/BindDatatable", url: '@Url.Action("hotels.aspx","BindDatatable")', /*data: "{}",*/ data: "{'ToValue':'"+totval+"',"+"'checkin':'"+chkin+"',checkout:'"+ckhout+"'}", /*data:{ToValue:totval,checkin:chkin,checkout:ckhout},*/ dataType: "json", success: function(data) { var theHtml = data.d; // alert(data.d); window.location.href = data.d; }, error: function(xhr, textStatus, errorThrown) { //alert("Error is " + result.value); alert("FAIL: " + xhr + " " + textStatus + " " + errorThrown); } });





但收到错误



内部服务器错误



什么是错误。

i传递来自WebMEthod的参数,这些参数位于数据{}中ajax post



和asp.net hotels.aspx页面,我使用WebMethod



请咨询



but get error as

internal server error

what is error.
i pass parameters in WebMEthod from here , which are in data{} in ajax post

and in asp.net hotels.aspx page , i use WebMethod

pls advice


错误发生在hotels.aspx.cs页面中。调试页面以获取错误。
the error is in hotels.aspx.cs page. Debug the page to get the error.


评论该行

contentType:application / json; charset = utf-8,



删除表格

int roomcnt = Convert.ToInt32(HttpContext.Current.Request [selectroomname]);
comment the line
contentType: "application/json; charset=utf-8",

remove Forms
int roomcnt = Convert.ToInt32(HttpContext.Current.Request["selectroomname"]);


这篇关于ajax发布内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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