Wiki preview uses 'post' instead of 'get' (Closes #918)
[platal.git] / htdocs / javascript / ajax.js
index 33cd83b..a5c5982 100644 (file)
@@ -76,6 +76,8 @@ function AjaxEngine()
                     }
                 } else if (ajax.xml_client.status == 403) {
                     window.location.reload();
+                } else if (ajax.xml_client.status >= 500) {
+                    alert("Une erreur s'est produite lors du traitement de la requête");
                 }
             }
         };
@@ -126,7 +128,7 @@ function showTempMessage(id, message, success)
 
 function previewWiki(idFrom, idTo, withTitle, idShow)
 {
-    var text = encodeURIComponent(document.getElementById(idFrom).value);
+    var text = document.getElementById(idFrom).value;
     if (text == "") {
         return false;
     }
@@ -134,18 +136,22 @@ function previewWiki(idFrom, idTo, withTitle, idShow)
     if (!withTitle) {
         url += "/notitle";
     }
-    Ajax.update_html(idTo, url + "?text=" + text);
+    $.post(url, { text: text },
+        function(data) {
+            $("#" + idTo).html(data);
+        },
+        'text');
     if (idShow != null) {
         document.getElementById(idShow).style.display = "";
     }
 }
 
-function sendTestEmail(token, forlife)
+function sendTestEmail(token, hruid)
 {
-    Ajax.update_html(null, 'emails/test' + (forlife == null ? '' : '/' + forlife) + '?token=' + token,
+    Ajax.update_html(null, 'emails/test' + (hruid == null ? '' : '/' + hruid) + '?token=' + token,
                      function() {
                         showTempMessage('mail_sent', "Un email a été envoyé avec succès"
-                                        + (forlife == null ? " sur ton adresse." : " sur l'adresse de " + forlife),
+                                        + (hruid == null ? " sur ton adresse." : " sur l'adresse de " + hruid),
                                         true); });
     return false;
 }