Bonjour à tous,
Voici mon problème :
Je tente d'accéder à un web service avec JQuery et Ajax. Si je me connecte en local sur le serveur cela fonctionne très bien mais lorsque je me connecte sur le web sur ce serveur, ça ne fonctionne plus et j'ai un message d'erreur 404 - Fichier introuvable etc...
Voici mon code Javascript :
Et voici le code behind :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 <script language="javascript" type="text/javascript"> function OnContactChangedAdmin() { var id = document.getElementById("<%= DropDownListContactsAdmin.ClientID %>").value; $.ajax({ url: '/AutoComplete.asmx/GetCompany', type: "POST", dataType: "json", data: { contactid: id }, success: function(data) { $('#<%= CompanyContactAdmin.ClientID %>').fadeOut().text(data.CompanyName).fadeIn(); $('#<%= CityContactAdmin.ClientID %>').fadeOut().text(data.City).fadeIn(); $('#<%= ProvinceContactAdmin.ClientID %>').fadeOut().text(data.Province).fadeIn(); }, error: function(xhr, status, error) { alert("failed" + xhr.responseText); } }); } </script>
J'ai essayé de changer mon URL de plein de façon différente et rien n'a changé. J'ai essayé de voir ce que je pouvais changer dans IIS mais pareil aucun changement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 [System.Web.Services.WebMethod] [System.Web.Script.Services.ScriptMethod] public void GetCompany(string contactid) { int id = int.Parse(contactid); vw_Company infos = new Listings().GetInfosContact(id); string json = JsonConvert.SerializeObject(infos); this.Context.Response.ContentType = "application/json; charset=utf-8"; this.Context.Response.Write(json); }
Si vous avez une idée merci d'avance.
Partager