Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1158 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Other Programming Languages :

ajax send problem

Thread title: ajax send problem
Closed Thread    
    Thread tools Search this thread Display Modes  
05-23-2007, 11:06 PM
#1
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old  ajax send problem

I am trying to send 2 variables via get to a php page. If I send one or the other, it will work, but it wont read both, here is the command

Code:
function ajaxFunction()
{
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
			if(xmlHttp.responseText != "yes")
			{
				document.myForm.time.value=param;
			}
			else
			{
				document.myForm.time.value=xmlHttp.responseText;
			}
        }
      }
    xmlHttp.open("GET","time.php",true);
    xmlHttp.send('name=' + document.myForm.username.value + '&password=' + document.myForm.password.value);
}
This is where the problem would be
Code:
    xmlHttp.send('name=' + document.myForm.username.value + '&password=' + document.myForm.password.value);
Is there anything wrong with this?

05-23-2007, 11:24 PM
#2
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

You don't want to be sending anything within the send() call since this is a GET request. That would be alright if you were POSTing the data, but for a GET you just append the data to the URL ("time.php?name=...").

Code:
var url = "time.php?name=" 
        + document.myForm.username.value 
        + "&password=" 
        + document.myForm.password.value;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed