Hi,
I'm using the following js script to load a usercontrol via AJAX, but i keep getting the error bellow:
function LoadContribution(Id, divId) {
alert('teste2');
var data = {};
data.Id = Id;
$.ajax({
url: 'myPage.aspx/LoadExtendedDetail',
method: 'POST',
dataType: "json",
contentType: 'application/json',
data: JSON.stringify(data)
}).done(function (response) {
alert("teste 3");
console.log(response);$('#' + divId).html(response.d);
}).fail(function (err) {
console.log(err);
});
}<System.Web.Services.WebMethod()>
Public Shared Function LoadExtendedDetail(ByVal myId As String) As String
'Thread.Sleep(2000)
ExceptionUtility.LogInfo("myId : " & myId )
Using page As New Page
Dim userControl As UserControl = DirectCast(page.LoadControl("App_Controls/ExtendedDetail.ascx"), UserControl)
'userControl.myId = myId
Using writer As New StringWriter()
page.Controls.Add(userControl)
HttpContext.Current.Server.Execute(page, writer, False)
Return writer.ToString()
End Using
End Using
End Function"{"Message":"An attempt was made to call the method \u0027LoadContributionExtendedDetail\u0027 using a GET request, which is not allowed.","StackTrace":" at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}"The LoadContribution function is called when i press a link and the the error above is fired
I also can't understand why the error detail keeps pointing to a GET request when i have the AJAX code set to use POST...
I've also attempted to change the instantiation of the usercontrol within the webmethod to
Dim userControl As App_Controls_ExtendedDetail = DirectCast(page.LoadControl("App_Controls/ContributionExtendedDetail.ascx"), App_Controls_ExtendedDetail)and i have the App_Controls_ExtendedDetail control registered on the aspx page, but i keep getting an error stating that the control is ambiguous.
Any ideia how to solve these two issues?