Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-30-2012, 10:11 AM   PM User | #1
joseph.ranjan
New to the CF scene

 
Join Date: Jan 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
joseph.ranjan is an unknown quantity at this point
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 ?
joseph.ranjan is offline   Reply With Quote
Old 01-30-2012, 10:15 AM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,261
Thanks: 10
Thanked 533 Times in 527 Posts
devnull69 will become famous soon enough
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
devnull69 is offline   Reply With Quote
Old 01-30-2012, 10:19 AM   PM User | #3
joseph.ranjan
New to the CF scene

 
Join Date: Jan 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
joseph.ranjan is an unknown quantity at this point
Thanks a lot sir ... do i need to decode in php in that case ?
joseph.ranjan is offline   Reply With Quote
Old 01-30-2012, 10:59 AM   PM User | #4
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,261
Thanks: 10
Thanked 533 Times in 527 Posts
devnull69 will become famous soon enough
nope ... this is being automatically taken care of
devnull69 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:37 PM.


Advertisement
Log in to turn off these ads.