Connecting Tech Pros Worldwide Forums | Help | Site Map

A request to a php file with no data sent

Familiar Sight
 
Join Date: Jun 2008
Posts: 164
#1: Aug 29 '08
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.  

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,662
#2: Aug 29 '08

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?
Ferris's Avatar
Member
 
Join Date: Oct 2007
Location: Shanghai
Posts: 102
#3: Aug 30 '08

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