SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot phpguru's Avatar
    Join Date
    Sep 2005
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    nbsp; and XMLHttpRequest sending method

    here's my example:

    HTML Code:
    var string = "  sh*t ajax";
    xmlhttp.onreadystatechange = TransResp;
    xmlhttp.open("POST",url,true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    	xmlhttp.send(
    		"string="+string
    	);
    	return true;
    And here's my resuld $_POST["string"] is blank ???

    and only when i change my string become: "shi*t ajax"; then POST string return exactly value

    i don't know what's going on with XMLHttpRequest ???

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you send multiple variables via POST, you separate them with the ampersand character like:

    string1=this&string2=that

    so the & in your first   is causing the "string" variable to be empty.

    Try using %26 instead of &

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,824
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    "string=" + encodeURIComponent(string)
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Zealot phpguru's Avatar
    Join Date
    Sep 2005
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what different between encodeURI and encodeURIComponent ?


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
  •