Bonjour,
j'aimerai bien pourvoir faire le post de ce formulaire via ajax mais je n'y arrive pas.
voici la vue :et ici le script :
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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 <form id="forlaire"> <table style="font:bold 12px message-box,blue;"> <tbody> <tr> <td>@Html.Label("Nom ou Raison Sociale")</td> <td>@Html.EditorFor(m => m.cust.name)</td> <td>@Html.Label("Telephone")</td> <td>@Html.EditorFor(m => m.cust.phone)</td> </tr> <tr> <td>@Html.Label("email")</td> <td>@Html.EditorFor(m => m.cust.email)</td> <td>@Html.Label("Ville")</td> <td>@Html.DropDownListFor(m => m.cust.city_id, new SelectList(Model.CityItems, "Value", "Text"))</td> </tr> <tr></tr> <tr> <td>@Html.Label("Domiciliation Travaux")</td> <td>@Html.EditorFor(m => m.cust.Dom_Travaux)</td> <td>@Html.Label("Point de repère")</td> <td>@Html.EditorFor(m => m.cust.point_repere)</td> </tr> <tr> <td>@Html.Label("Description des Travaux")</td> <td>@Html.TextAreaFor(m => m.cust.Descr_Travaux)</td> <td>@Html.Label("Technicien sollicité")</td> <td>@Html.DropDownListFor(m => m.cust.Techn_Solicité, new SelectList(Model.TachesItems, "Value", "Text"))</td> </tr> <tr> <td>@Html.Label("Durée Probable Travaux(jours)")</td> <td>@Html.EditorFor(m => m.cust.Dur_Probalbe)</td> </tr> <tr></tr> <tr> <td></td> <td></td> </tr> </tbody> </table> </form> <a href="javascript:CancelFile()">Annuler</a> <a href="javascript:deTravaux()">Validez vos informations</a> <img id="loading" style="display:none" src="~/Content/Images/indicator.gif" alt="image d'attente'" />
et le modèle de la vue :
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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 function deTravaux() { //formulaire = $("#forlaire"); //if (!formulaire.validate().form()) { // // formulaire invalide - terminé // return; //} $.ajax({ url: '/RLT/SaveDT', type: 'POST', data: formulaire.serialize(), datatype: 'html', beforeSend: function () { loading.show(); }, sucess: function (data) { content.html(data); } //error: function (resultat, statut) { // content.html(resultat.reponseText); // //content.appendTo(statut); //} }); } $(document).ready(function () { // on récupère les références des différents composants de la page loading = $("#loading"); content = $("#content"); formulaire = $("#forlaire"); loading.hide(); });
ce code ne produit aucune réaction et la console du navigateur ne relève pas d'erreur non plus. quelqu'un pourrait m'aider svp. je galère vraiment.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 public class TravauxModel { public customers cust { get; set; } public ApplicationModel Application { get; set; } public SelectListItem[] TachesItems { get; set; } public SelectListItem[] CityItems { get; set; } }
Merci bien.
Prisson
Partager