开发者

trying to send extended characters via ajax

I have the following jQuery Ajax function which sends the following data to a asp 开发者_运维百科page.

name=Högberg

This is the ajax function...

function senddata(){
jQuery.ajax({
url: "/vsmtp.asp",
type: 'POST',
data: 'name=Högberg',
cache: false,
success: function(data){
    alert('success');
              } 
       })
}

My problem is that when I look at the actual text in the POST in Firebug it is sending the following.

name=H�gberg

How can I encode it such that is sends the correct characters? Thanks.


It turns out I needed to simply escape the data to get it working.

function senddata(){
var str= "name=Högberg";
jQuery.ajax({
url: "/vsmtp.asp",
type: 'POST',
data: escape(str),
cache: false,
success: function(data){
alert('success');
              } 
       })
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜