This is a fragment of the webservice:
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)],
[System.ComponentModel.ToolboxItem(false)],
[System.Web.Script.Services.ScriptService])
public class ClientServei : System.Web.Services.WebService
{
[WebMethod]
public List<Client> GetClient()
{
List<Client> Listclient = new List<Client>();
Listclient.Add(new Client() { Nombre = "OSCAR", Apellido = "PUIG", Edad = 30 });
Listclient.Add(new Client() { Nombre = "JORDI", Apellido = "FERRER", Edad = 31 });
Listclient.Add(new Client() { Nombre = "MIQUEL", Apellido = "MAR", Edad = 31 });
return Listclient;
}
}
And this is the jQuery click function that I use to call the AJAX function:
$("#prova").click(function () {
$.ajax({
url: "ClientServei.asmx/GetClient",
data: "{}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
alert("success");
},
error: function (response) {
alert("error");
},
failure: function (response) {
alert("arriva failure");
}
});
});
I have captured the errors in the alert and I get: "Requested page not found [404]"
.
What could be the reason why this webservice is not being used correctly?