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
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Data crashing when sending via Ajax call

    Hello All,

    I need some help on how the data can be passed in ajax without js crashed ....

    My query string was formed like this ...

    "attribute1="+data1+"&attribute2="+data2+"&attribute3="+data3+"&attribute4="+data1

    It was getting crashed sometime when i pass some text having some spl characters in it ... is there anyway by which we can clean the data and pass in javascript ?

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Yes there is. All the URL parameters have to be URI compliant (so special characters need to be converted). You should use the encodeURIComponent() method on every parameter prior to concatenating
    Code:
    data1 = encodeURIComponent(data1);
    data2 = encodeURIComponent(data2);
    data3 = encodeURIComponent(data3);
    data4 = encodeURIComponent(data4);
    parameters = "attribute1="+data1+"&attribute2="+data2+"&attribute3="+data3+"&attribute4="+data4

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot sir ... do i need to decode in php in that case ?

  • #4
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    nope ... this is being automatically taken care of


  •  

    Posting Permissions

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