Developer forum

Forum » Templates » Best practices submitting form without reload with ajax or similar

Best practices submitting form without reload with ajax or similar

Hans Ravnsfjall
Hans Ravnsfjall

I am trying to submit a form without reloading the page, but i keep locking my self out getting my IP banned

I have tried this by using Ajax. The solution I am working on is a 9.12

Anyone got a suggestion on how I can do this, without having to disable the spam filter on the page, and ofcourse - without getting banned (BannedIP.txt)



Nicolai Pedersen
Nicolai Pedersen

You can use fetch and post the entire page using formdata object. Then when the response from the post returns with code 200, update the forms page - either with the response from the fetch or your custom implementation.

When you do, remember to fire Dynamicweb antispam script first. The forms onsubmit attribute contains the script, which will look something like this (the ids changes all the time, so you cannot hardcode it):

s=function(e){e.elements['FormCH1_h'].value='fbaffa6c92f285df22f1755f8f0b1779';e.elements['_sys_to_email'].value='';e.setAttribute('action', '/Default.aspx?ID=106&PID=2761');return true};return s(this);

You can get that script from this tag:


Something like this:

var dynamicwebForm = document.getElementById('dw-form-1');
//Call the Form.OnSubmit code here...
const form = new FormData(dynamicwebForm);
fetch('/login', {
  method: 'POST',
  body: form

Read full docs here:



You must be logged in to post in the forum