If you are using Javascript to make an asynchronous request (AJAX) then you would need to enure that the target URL is included, this can be included by just echoing it in where required.
I have knocked up a very simple example using a couple of php pages (source and target) and a javascript file.
File 1 (the one to open in your browser):
-
<?xml version="1.0" encoding="utf-8" ?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
<head>
-
<title>AJAX Test</title>
-
<script src="script.js" type="text/javascript"></script>
-
</head>
-
<body>
-
<form id="test" action="page1.php" method="post">
-
<h1>This is a test page to show an AJAX request.</h1>
-
<p>The slow button below will send an asynchronous request to a page which uses sleep() to mock a long running process. The value in the textbox
-
is the number of seconds to sleep for.</p>
-
<p><label>Duration: <input type="text" name="txtDur" id="txtDur" value="5" /></label></p>
-
<p><label>Make Asynch: <input type="checkbox" name="chkAsynch" id="chkAsynch" checked="true" /></label></p>
-
<p><input type="submit" name="btnSub" id="btnSub" value="Slow" /></p>
-
<p><a id="responsive" href="#">Click to test responsive</a></p>
-
<div id="res"></div>
-
</form>
-
</body>
-
</html>
-
This is just static HTML, the form would post back to the same page if javascript is not enabled or working correctly.
File 2 (the page the request is made to):
-
Start Time:
-
<?php
-
// current time
-
echo date('h:i:s');
-
?>
-
, Finish Time:
-
<?php
-
// sleep for 10 seconds
-
sleep($_POST["duration"]);
-
// wake up !
-
echo date('h:i:s');
-
?>
-
Javascript
You should be able to compare an asynchronous request, page is totally responsive, and a synchronous request, page is frozen until request completes.