I am having a question about JQuery Ajax, I researched some examples online, which put ajax code and static web method in the same asp.net page. What I am trying to do is to put ajax code in ascx control, and the static webmethod in a aspx page that contains the control. Is it feasible? From my test, I got problem that "the server responded with a status of 404".
static web method:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]
public static List<AppUtils.vAdviseComponent> GetPDFReport()
{
//AppUtils.vAdvise.GetAllComponents(currentAssembelyID);
List<AppUtils.vAdviseComponent> assebmblyCompList = null;
assebmblyCompList = AppUtils.vAdvise.GetAllComponents(14);
return assebmblyCompList;
}
JQuery ajax code in the control
var tablecontent;
$j(function onSuccess(data) {
tablecontent = {
content: [
{
fontsize: 8,
table: {
headerrows: 1,
widths: ['auto', 'auto', 'auto', 'auto', 'auto'],
body: [
[{ text: 'id', bold: true }, { text: 'component name', bold: true }, { text: 'cage code', bold: true },
{ text: 'nsn', bold: true }, { text: 'part number', bold: true}],
]
}
}
]
};
tablecontent.content[0].table.body.push("shit");
});
$j("#pdfExtractBtn").button().on("click", function getPDFSummary() {
$j.ajax({
type: "post",
url: "vAdviseConfigurations.aspx/getPDFReport",
data: "{}",
datatype: "json",
contenttype: "application/json; charset=utf-8",
success: onSuccess,
error: function () {
alert("There was an error");
}
});
});
so my question is that do I have to put the ajax code and web method in the same asp.net page? Thanks in advance!
通过测试和在线示例,我认为我们不能在两个单独的页面类中执行JQuery AJAX。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.