gpt4 book ai didi

c# - 意外的 token > jquery ajax

转载 作者:太空宇宙 更新时间:2023-11-03 13:04:43 25 4
gpt4 key购买 nike

我正在对 Web 方法进行 ajax 调用,但收到错误“意外 token >”我不确定为什么会收到此消息。有什么想法吗?

function addToQueue(me) {

if (validateTimeFrame()) {
$.ajax({
method: "POST",
url: "GenerateReportModal.aspx/AddToPrintQueue?id=" + $('#patientNum').val(),
data: {buttonID: me.id},
dataType: "json",
success: function (data, textStatus, jqXHR) {
alert(data);
$('#GenerateReportModal').dialog('close');
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown + ' ' + textStatus);
console.log(jqXHR);
$('#GenerateReportModal').dialog('close');
}
});
}
}

<-------------------------------------------- ->

[WebMethod]
public string AddToPrintQueue(string buttonID)
{
try
{
var deIdentify = 0;
var adminUserNum = Int32.Parse(Session["AdminUserNum"].ToString());

if ((Session["AdminUserNum"].ToString() == "6460" || Session["AdminUserNum"].ToString() == "6537" || Session["AdminUserNum"].ToString() == "7885") && (Session["ClinicalDataAdmin"].ToString() == "1" || Session["AccountAdmin"].ToString() == "1" || Session["SystemAdmin"].ToString() == "1"))
deIdentify = (cbDeIdentify.Checked == true) ? 1 : 0;
else
deIdentify = 0;

switch (buttonID)
{
case "FollowUpAddtoQueue":
FollowUpAddToQueueClass(deIdentify);
break;
case "WearTimeAddToQueue":
WearTimeAddToQueueClass(deIdentify);
break;
case "TrendsAddToQueue":
TrendsAddToQueueClass(deIdentify);
break;
case "EndOfUseAddToQueue":
EndofUseAddToQueueClass(deIdentify);
break;
}
}
catch
{
return "There was an issue, we appologize for the inconvenience";
}

return "Added to print queue";
}

<-------------------------------------------- ------>

<asp:Button runat="server" OnClientClick="return addToQueue(this); return false;" CssClass="button" ID="EndOfUseAddToQueue" Width="150" Text="<%$ Resources:PatientDetail, btnModAddtoQueue %>" />

最佳答案

您正在从您的 Web 方法返回一个字符串,但您已经告诉 jQuery 期待 JSON。

$.ajax({
//...
dataType: "json",
//...
});

将其更改为文本(或将其完全删除),看看是否能解决您的问题。请参阅 jQuery AJAX documentationdataType 属性.

关于c# - 意外的 token > jquery ajax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31160725/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com