Monday, July 20, 2009

Call the php file using javascript.

we can the call the php file in javascript following syntax:

<?php

//"ip.php" example- display user IP address on any page
header("content-type: application/x-javascript");
$serverIP=$_SERVER['REMOTE_ADDR'];
echo "document.write(\"Your IP address is: " . $serverIP . "\")";

?>

to call the php file in html file like

<script type="text/javascript" src="ip.php"></script>




Hope it will be helpful.

Anil Kumar Panigrahi

1 comment: