Closed Thread
Results 1 to 2 of 2

Thread: POST via Javascript to PHP

  1. #1
    Join Date
    Mar 2010
    Posts
    15
    Rep Power
    0

    POST via Javascript to PHP

    ok my question has to do with using the javascript post to then send multiple params to php.....

    Code:
    // Instance Variables
            var params = "username=" + username + "$email=" + email + "$message=" + message;
              var XMLHttpRequestObject = getXMLHttp();
            
            if (XMLHttpRequestObject) {
                
                // Opens dataSource and recives data
                XMLHttpRequestObject.open("POST", dataSource);
                
                // Post Headers
                XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                XMLHttpRequestObject.setRequestHeader("Content-length", params.length);
                XMLHttpRequestObject.setRequestHeader("Connection", "close");
                
                XMLHttpRequestObject.onreadystatechange = function() {
                    if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                        HandleResponse(XMLHttpRequestObject.responseText, divID);
                    }
                }
                XMLHttpRequestObject.send(params);
            }
    the out put of this is.....

    Code:
    From: Brian Gebel$email=email@address$message=OMG I HOPE THIS WORKS
    E-Mail: 
    Message:
    when it should be this
    Code:
    From: Brian Gebel
    E-Mail: email@address
    Message:
    OMG I HOPE THIS WORKS

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Mar 2010
    Posts
    15
    Rep Power
    0

    Re: POST via Javascript to PHP

    OK i figured it out.... simple realy
    this line
    Code:
    var params = "username=" + username + "$email=" + email + "$message=" + message;
    should be this....
    Code:
    var params = "username=" + username + "&email=" + email + "&message=" + message;
    the difference being
    $in thte first and &in the second

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Javascript IDE
    By jwxie518 in forum Software Development Tools
    Replies: 2
    Last Post: 08-09-2011, 05:25 AM
  2. javascript help
    By -Hurricane- in forum JavaScript and CSS
    Replies: 3
    Last Post: 05-06-2010, 06:53 AM
  3. javascript help
    By hkp in forum JavaScript and CSS
    Replies: 2
    Last Post: 06-04-2009, 11:55 PM
  4. Javascript
    By seal in forum Java Help
    Replies: 1
    Last Post: 06-22-2007, 12:35 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts