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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool Help passing a URL as param via POST

    Hello, I'm new to using Ajax but pretty good with Javascript, but am stuck on something I writing and need some help.

    I am passing a XMLHttp request via post and passing some parameters to it. The code is working fine and dandy, and I am using a name/value pair string to pass the parameters as such:
    Code:
    params = "name="+ value+ '&r=' + Math.random();
    My problem is this: one of the values I am passing is a URL, which may contain its own query string attached to it. (Imagine a bookmarking type script) If I pass it along as url=url&myotherdata=data... the name/value pairs of the get mixed up when I'm reading it later on my php script.

    Any suggestions?

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Bmiller View Post
    Hello, I'm new to using Ajax but pretty good with Javascript, but am stuck on something I writing and need some help.

    I am passing a XMLHttp request via post and passing some parameters to it. The code is working fine and dandy, and I am using a name/value pair string to pass the parameters as such:
    Code:
    params = "name="+ value+ '&r=' + Math.random();
    My problem is this: one of the values I am passing is a URL, which may contain its own query string attached to it. (Imagine a bookmarking type script) If I pass it along as url=url&myotherdata=data... the name/value pairs of the get mixed up when I'm reading it later on my php script.

    Any suggestions?
    I'm not sure I understand the problem but for your example params must look like this:
    Code:
    params = 'url=' + escape(url) + '&myotherdata=' + escape(data);
    name must be explicit and usualy is better to escape value.

    best regards

  • Users who have thanked oesxyl for this post:

    Bmiller (02-12-2009)

  • #3
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks, that did it! I think my brain was just a bit overloaded from a little too much work.

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Bmiller View Post
    Thanks, that did it!
    you are welcome,

    I think my brain was just a bit overloaded from a little too much work.
    no problem, it's happend,

    best regards


  •  

    Posting Permissions

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