954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Calling a PHP file from a javascript code

Hello everyone

I am developing an application in which , i wrote the code for a pop up confirmation box in javascript, & when it presees ok , i want to call a PHP file from javascript......tried but not working......if anybody can help, would be great......

roja.

rojakc
Newbie Poster
1 post since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

I have the same problem - please help me out.

How can i call php file in javascript file..?? My pop ups are not working because of this.

Thanks in advance.
Thanks
harsh

harshpandya
Newbie Poster
1 post since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

Hi There,

I have Made Very Basic Example for you that will help you to understand how to use confirmation Box (confirm() JavaScript) in PHP

here is the code :

test.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP Page</title>
<script type="text/javascript">
function confirmation(url, id) 
{
	var where_to= confirm("Do you really want Add the Value??");
		if (where_to== true)
			{
			window.location=url+"?"+id;
			}
			else
			{
			alert("Action Aborted By User!")
			}
} 
</script>
</head>
<body>
<a href="javascript:void(0);" onClick="confirmation('test.php', 'val=Just Testing')" id="links">Link Text</a>
<?php 
if($_GET['val'] != "")
	{
		echo "this value came From Last Page: ".$_GET['val']; 
	}
	?>
</body>
</html>


I hope this code will help you

Rahul Dev Katarey

katarey
Junior Poster
167 posts since Jul 2005
Reputation Points: 39
Solved Threads: 23
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You