# Loading PHP result into DIV using Ajax



## Swanny86uk (Dec 1, 2006)

Hi all,

I'm trying to get the result of an external PHP script (which processes form data) to load into a DIV on the same page as the submission form. Tried a few different ideas I've came across on the net but no luck so far. Does anyone have any ideas on how to do this or any links where I can find out - driving me mad this is 

Cheers,

Marc


----------



## Mr.LLB (May 27, 2008)

can i see what you have done?


----------



## Swanny86uk (Dec 1, 2006)

Sure thing,

Got the following PHP code that performs a few calculations and then echo's them;


```
<?php

		$field1 = $_POST['field1'];
		$field2 = $_POST['field2'];
		$field3 = $_POST['field3'];
		$field4 = $_POST['field4'];

		$CurrentRevenue = (($field1 * $field2) / 100) * $field3;
		$PotentialRevenue = (($field1 * $field4) / 100) * $field3;

		echo "£".$CurrentRevenue . "

 " . "£".$PotentialRevenue;
?>
```
I want the result of the script (whatever I echo) to be printed within a DIV on the form page.

Any ideas?


----------



## Mr.LLB (May 27, 2008)

http://www.w3schools.com/PHP/php_ajax_database.asp

^ this page gives you a good overview of what you need to do. your php script seems to be fine so just do the ajax part from this page


----------

