Last modified by Alex Cotiugă on 2026/05/04 06:15

From version 13.157
edited by Alex Cotiugă
on 2026/05/02 09:06
Change comment: There is no comment for this version
To version 13.102
edited by Alex Cotiugă
on 2026/05/02 08:26
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,25 +23,3 @@
1 -{{velocity wiki="false"}}
2 -#if ($xcontext.action == 'get')
3 - #set ($message = '')
4 - #set ($now = $datetool.get('yyyyMMddHHmm'))
5 - #set ($random = $mathtool.random(100000, 999999))
6 - #set ($uniqueName = "contact-request-${now}-${random}")
7 - #set ($contactFormEntryDoc = $xwiki.getDocument('ContactRequests.' + $uniqueName))
8 - #set ($statusCode = 200)
9 - #set ($message = "$contactFormEntryDoc")
10 -
11 - #foreach ($parameterName in $request.parameterNames)
12 - #set ($message = "$message $parameterName")
13 - #end
14 -
15 - ##set ($statusCode = 400)
16 - ##set ($message = 'error')
17 -
18 - #set ($discard = $response.setStatus($statusCode))
19 - #jsonResponse({'message': $message})
20 -#end
21 -{{/velocity}}
22 -
23 23  {{velocity}}
24 24  #set ($discard = $xwiki.ssx.use('contact.WebHome'))
25 25  #set ($xobject = $doc.getObject('Agnease.Code.ContactForm.ContactFormClass'))
... ... @@ -63,22 +63,6 @@
63 63   ##<p>Your information will only be used to respond to this request. See the Privacy Policy for details.</p>
64 64   <input id="contactSubmit" type="submit" class="btn btn-primary" value="Send my request">
65 65   </form>
66 - {{/html}}
67 - {{html clean="false" wiki="true"}}
68 - <div class="reviewNotifications">
69 - <div class="hidden reviewNotificationSuccess">
70 -
71 - {{success}}reviewNotification{{/success}}
72 -
73 - </div>
74 - <div class="hidden reviewNotificationError">
75 -
76 - {{error}}reviewNotification{{/error}}
77 -
78 - </div>
79 - </div>
80 - {{/html}}
81 - {{html clean="false"}}
82 82   </div>
83 83   <div class="col-xs-5">
84 84   <div class="widget">
... ... @@ -100,6 +100,20 @@
100 100   <li>If useful, we schedule a short call to discuss scope, timeline, and estimated effort.</li>
101 101   </ol>
102 102   </div>
65 + {{/html}}
66 + {{html clean="false" wiki="true"}}
67 + <div class="reviewNotifications">
68 + <div class="hidden reviewNotificationSuccess">
69 +
70 + {{success}}reviewNotification{{/success}}
71 +
72 + </div>
73 + <div class="hidden reviewNotificationError">
74 +
75 + {{error}}reviewNotification{{/error}}
76 +
77 + </div>
78 + </div>
103 103   </div>
104 104   </div>
105 105  {{/html}}
XWiki.JavaScriptExtension[0]
code
... ... @@ -1,5 +1,5 @@
1 1  require(['jquery'], function ($) {
2 - var serviceURL = new XWiki.Document('WebHome', 'contact').getURL('get');
2 + var serviceURL = new XWiki.Document('WebHome', 'content').getURL('get', 'xpage=plain');
3 3   var form = $('#contactForm');
4 4   var submitButton = $('#contactSubmit');
5 5  
... ... @@ -6,6 +6,20 @@
6 6   var successBox = $('.reviewNotificationSuccess');
7 7   var errorBox = $('.reviewNotificationError');
8 8  
9 + var nameFieldName = 'Agnease.Code.ContactForm.ContactFormClass_0_name';
10 + var emailFieldName = 'Agnease.Code.ContactForm.ContactFormClass_0_email';
11 +
12 + function getFormData() {
13 + var data = {};
14 +
15 + $.each(form.serializeArray(), function (_, field) {
16 + data[field.name] = field.value;
17 + });
18 + console.log(data)
19 +
20 + return data;
21 + }
22 +
9 9   form.on('submit', function (event) {
10 10   event.preventDefault();
11 11  
... ... @@ -28,7 +28,7 @@
28 28   form[0].reset();
29 29   }).fail(function (xhr) {
30 30   var errorBoxContent = errorBox.find('.box div p');
31 - errorBoxContent.text(xhr.statusText);
45 + errorBoxContent.text(xhr.responseJSON.message);
32 32   errorBox.toggleClass('hidden');
33 33   if (successBox.is(':visible')) {
34 34   successBox.toggleClass('hidden');