Connecting Tech Pros Worldwide Help | Site Map

A request to a php file with no data sent

  #1  
Old August 29th, 2008, 03:47 PM
Familiar Sight
 
Join Date: Jun 2008
Posts: 164
I want to get data from an external php file. This is how I would normally do it but this time I am not sending any data in the request. How do I achieve this when no data is being sent in the request?

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="text-utils.js"> </script>
  2. <script type="text/javascript" src="request.js"> </script>
  3. <script type = "text/javascript">
  4. window.onload = function() {
  5.     getProjects();
  6. }
  7. function getProjects() {
  8.     var url = "needmodule.php";
  9.     url = url + "&dummy=" + new Date().getTime();
  10.     request.open("GET", url, true);
  11.     request.onreadystatechange = updateProjects;
  12.     request.send(null);
  13. }
  14. function updateProjects() {
  15.     if (request.readyState == 4) {
  16.         var returned = request.responseText;
  17.         alert(returned);
  18. }
  19. </script>
  20.  
  #2  
Old August 29th, 2008, 09:45 PM
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,488
Provided Answers: 9

re: A request to a php file with no data sent


But you do send data. Although it's GET data...
Furthermore (this might be a writing mistake) shouldn't there be a "?" instead of an "&" in line 9?
  #3  
Old August 30th, 2008, 12:31 PM
Ferris's Avatar
Member
 
Join Date: Oct 2007
Location: Shanghai
Posts: 102

re: A request to a php file with no data sent


yes,Dormilich is right , and furthermore, you missed a } in line 17. It should be
[HTML]alert(returned); }[/HTML]
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP file displays code andersond answers 3 October 9th, 2007 05:50 PM
Form validation with PHP/Javascript Chris answers 27 September 1st, 2006 02:25 AM
how to tell server from PHP that charset is UTF-8?? lawrence answers 12 July 17th, 2005 09:47 AM
Call a local function or a separate PHP file? Titus Cheung answers 2 July 17th, 2005 02:37 AM