开发者

What would be the best JavaScript text encoding to use?

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 th开发者_如何转开发e 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!


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


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) { }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜