Pratik Joshi
Pratik Joshi

Reputation: 11693

jQuery/javascript : how to accept special chars and send it through ajax using json?

I tried btoa()

btoa("Chars to encode");

Fiddle

But it doesnot work properly with mobile characters

I used encodeURIComponent() also but it makes string LONG and json has 256 chars limitation on sending data so it is issue .

What would be correct solution for it ? thanks

Upvotes: 0

Views: 140

Answers (1)

dmikam
dmikam

Reputation: 1082

First of all json is not limited to 256 symbols. I suppose you are sending your data by GET method - it has limited length and could prevent you to sent special chars.

The solucion could me to use POST method in place of GET. Just use:

jQuery.post('http://you-url-here',{
    'data': 'string-with-special-chars',
    ....
},function(res){ ... },'json');

or almost the same using jQuery.ajax() method.

Upvotes: 1

Related Questions