Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 29th, 2008, 03:47 PM
Familiar Sight
 
Join Date: Jun 2008
Posts: 134
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, 09:45 PM
Dormilich's Avatar
Expert
 
Join Date: Aug 2008
Location: Leipzig, Germany
Age: 31
Posts: 646
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, 12:31 PM
Ferris's Avatar
Member
 
Join Date: Oct 2007
Location: Shanghai
Age: 22
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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 network members.
Post your question now . . .
It's fast and it's free

Popular Articles