Connecting Tech Pros Worldwide Help | Site Map

A request to a php file with no data sent

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 29th, 2008, 02:47 PM
Familiar Sight
 
Join Date: Jun 2008
Posts: 161
Default A request to a php file with no data sent

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.  
Reply
  #2  
Old August 29th, 2008, 08:45 PM
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Age: 32
Posts: 2,227
Default

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?
Reply
  #3  
Old August 30th, 2008, 11:31 AM
Ferris's Avatar
Member
 
Join Date: Oct 2007
Location: Shanghai
Age: 23
Posts: 102
Default

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

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.