Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AJAX Sucess() giving me trailing whitespace

    Hey guys,
    I'm new to this forum, and to Javascript...

    I have a Javascript AJAX request that looks something like this:

    Code:
      success: function(hello){   // the result is put into the Text input named qty
    						   
    						   
    						   $("#qty").val(hello);
    							console.log(hello);  
    							document.getElementById("adding").style.visibility = "visible";
    						//	  console.log(hello);   // for debug use we can output to the console
    					   }
    When ever I look in the console, the output always appears like this:
    Code:
    "     6"
    I have echo'ed the php script and that is fine, somehow the javascript seems to be adding white spaces. I am using another AJAX request further on in my script, and that have exactly the same issue. Please help!

    Thanks!

    AndyJ

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,691
    Thanks
    25
    Thanked 657 Times in 656 Posts
    There are a few things missing. Like what is hello, is it a string or yeti? Maybe show what the console says. You know things that run and help us.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

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