I have a simple page. On load, it calls a web service, and then I get the following error:
an attempt was made to call the method using a GET request, which is not allowed
My JS-code:
function getTutors() {
var url = '<%= ResolveUrl("~/services/tutorservice.asmx/gettutors") %>';
$.ajax({
type: "GET",
data: "{'data':'" + 'test-data' + "'}",
url: url,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (d) {
alert('succes');
return d;
},
error: function () {
alert('fejl');
}
});
}
$(document).ready(function () {
var tutors = getTutors();
var locations = [];
}
My web service:
[ScriptService]
public class tutorservice : System.Web.Services.WebService {
public tutorservice () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public List<Tutor> gettutors(string data)
{
var tutorManager = new TutorManager();
return tutorManager.GetTutorApplicants();
}
}
I have tried to remove the contentTypes, and even without the data variable, it still gives the same error.
My best guess is some contentType / dataType should be removed, but I have tried that as well.
Any ideas about why I get this error?