views:

36

answers:

2

Hi guys.

I am creating a jQuery / AJAX search script, and I am trying to find the best text encoding to use on the string that gets sent to the waiting PHP file that will be doing the SQL query to get the results.

I was thinking Base64? But as I do not have a lot of experience in this field, I would appreciate any input that could help.

Thanx in advance!

+2  A: 

UTF-8. Also if you are using jquery you could always pass parameters in the data hash in order to properly encode them:

Always do:

$.ajax({
    url: '/script',
    data: { param1: 'someValue', param2: 'someOtherValue' },
    success: function(result) { }
});

instead of:

$.ajax({
    url: '/script?param1=someValue&param2=someOtherValue',
    success: function(result) { }
});
Darin Dimitrov
Thanx for the help.
+2  A: 

simple utf-8 text - but think of correct urlencoding to handle special chars (take a look at encodeURI())

oezi
Thanx, will give it a go!