Interaction with a webservice (javascript)

I made my first steps with webflow and I’m happy with all the things I can do without being a webdeveloper…

I’m coding backends and would like to use the output of webflow to interact with it. Is it right that there’s actually no way to interact with backends without exporting the site?

I’d like to:

  • register user
  • validate userlogins
  • display dynamic contents
  • make the user change personal details

Or is there a way to add javascript to the webflow code which will perform these actions and modify the content afterwards?

Thanks in advance
Sascha

You can always use jQuery to create dynamic content. Best way possible would be to use jQuery to send form values to your custom-hosted PHP script that will process all data. I think that’d be the best and easiest solution. I did it few times and worked perfectly. Remember that jQuery is visible within your code so be careful with how do you use that.

Sounds great! Is there any example or howto where I can add jquery requests and modify the content afterwards?

Let’s say you have a form like this:

Login: Password: Login: Password:

You can add jQuery code to process your data to your custom-hosted PHP script.

<script>
	function save() {
		var query = $('#formID').serialize();
		var url = 'processdata.php';
		$.post(url, query, function (response) {
			alert(response);
		});
	}
</script>

Using $.post(url, query, function(response) { ... }); lets you process data using POST to PHP. You can read them within your PHP using eg.

<?php
  $login = $_POST['name'];
  $pass = $_POST['pass'];
  echo 'Login: '.$login.'<br />Pass: '.$pass;
?>

Because your PHP will ECHO something it is considered as output which will be processed by function(response) { alert(response); }. That way it will alert what is echoed with PHP function.

You can return an array that can be processed to use some other functions or variables. Eg if value returned is blablabl you can show something else. You can also use PHP for something like “when you type something awesome in this box another HTML div will appear”. You can even set up whole pages.

Take a look at the following site I built: www.bartekkustra.eu/warsztat . You can go to “Samochody” and add new one. You can even select HTML table row and click “Edytuj” to edit stuff in there. Everything is connected to database and is processed using PHP :slight_smile:

3 Likes