Newbie Question - Working with RESPONSE after FORM POST!

Do you have the thens attached to it?

oh so I’m missing a couple of statements… !!

like so?

<script>

		let form = document.getElementById('FormName');

		form.addEventListener('submit', (event) => {
			// Prevent default form submission
			event.preventDefault();

			const formData = new FormData(form);

			fetch('https://click2call.aosystemsgroup.com/wcb.php', {
				method: 'POST',
				body: formData
			})
				.then(response => response.json())
				.then(data => {
					// Handle the server's response
					// console.log(data.Response);
					alert("Status response: " + data.Response + ".\nMessage: " + data.Message);

					// clear the field
					let webcallbackinput = document.getElementById('webcallbackinput');
					webcallbackinput.value = ""
				})
				window.location.replace("https://stackoverflow.com");

				.catch(error => {
					console.error('Error:', error);
				});
		});
	</script>

well now you need to combine the two, and tell the fetch where you want it to go.

oh gotcha… ok, let me fiddle with this.

Like so:

<script>

		let form = document.getElementById('FormName');

		form.addEventListener('submit', (event) => {
			// Prevent default form submission
			event.preventDefault();

			const formData = new FormData(form);

			fetch('https://click2call.aosystemsgroup.com/wcb.php', {
				method: 'POST',
				body: formData
			})
				.then(response => response.json())
				.then(data => {
					// Handle the server's response
					// console.log(data.Response);
					alert("Status response: " + data.Response + ".\nMessage: " + data.Message);

					// clear the field
					let webcallbackinput = document.getElementById('webcallbackinput');
					webcallbackinput.value = ""
				})
				window.location.replace("https://stackoverflow.com");

				.catch(error => {
					console.error('Error:', error);
				});
		});
	</script>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.