在$ .ajax中传递数据时出现500内部服务器错误 [英] 500 Internal Server Error when pass data in $.ajax
本文介绍了在$ .ajax中传递数据时出现500内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
i希望在$ .ajax中传递数据但是当我运行项目时我在c#代码中得到空数据并获得
500检查元素中的内部服务器错误
我的代码是:
hello,
i want pass data in $.ajax but when i run project i get null data in c# code and get
500 Internal Server Error in inspect element
my code is :
function refreshTime(options) {
$.ajaxService({
url: 'http://localhost:1549/Store/Pages/services.aspx?ServiceName=hello-world',
data:{ oldpassword: $('#oldpassword').val(), newpassword: $('#newpassword').val() },
onStartService: function () { $(options.target).addClass('loading'); },
onEndService: function () { $(options.target).removeClass('loading'); },
onResponse: function (response) {
if (response.result == '1') {
$.pushMessage({ message: 'success changed', messageClass: 'success-message', delay: 3000 });
}
else {
$.pushMessage({ message: 'error in change password', messageClass: 'success-message', delay: 3000 });
}
}
});
}
NameValueCollection ResponseResultCollection = new NameValueCollection();
protected void Page_Load(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(2200);
string serviceName = this.Request.QueryString["ServiceName"];
if (!string.IsNullOrEmpty(serviceName))
{
switch (serviceName.ToLower().Trim())
{
case ("hello-world"):
string oldpassword = Request["oldpassword"].ToString();//i get null this
string newpassword = Request["newpassword"].ToString();//and get null this
try
{
System.Web.Security.MembershipUser usr = System.Web.Security.Membership.GetUser();
if (usr.ChangePassword(oldpassword, newpassword))
ResponseResultCollection["result"] = "1";
else
ResponseResultCollection["result"] = "0";
}
catch (Exception ex) { Response.Write("An exception occurred: " + Server.HtmlEncode(ex.Message) + ". Please re-enter your values and try again."); }
break;
}
}
Response.Write(this.GenerateResponseResult());
Response.End();
}
private string GenerateResponseResult()
{
string result = "";
foreach (string key in this.ResponseResultCollection.AllKeys)
{
result += string.Format(",\"{0}\":\"{1}\"", key, this.ResponseResultCollection[key]);
}
if (!string.IsNullOrEmpty(result))
{
result = result.Substring(1);
result = "{" + result + "}";
}
return result.ToString();
}
推荐答案
.ajax但是当我运行项目时,我在c#代码中获取空数据并获取
500检查元素中的内部服务器错误
我的代码是:
.ajax but when i run project i get null data in c# code and get
500 Internal Server Error in inspect element
my code is :
function refreshTime(options) {
.ajaxService({
url:' http:// localhost:1549 / Store / Pages / services.aspx?ServiceName = hello-world',
data:{ oldpassword:
.ajaxService({ url: 'http://localhost:1549/Store/Pages/services.aspx?ServiceName=hello-world', data:{ oldpassword:
(' #oldpassword')。val( ),newpassword:
('#oldpassword').val(), newpassword:
这篇关于在$ .ajax中传递数据时出现500内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文