小编典典

jQuery发送字符串作为POST参数

ajax

我想发送一个字符串作为ajax Post参数。

如下代码:

$.ajax({
   type: "POST",
   url: "http://nakolesah.ru/",
   data: 'foo=bar&ca$libri=no$libri',
   success: function(msg){
     alert('wow'+msg);
   }
});

不管用。为什么?


阅读 224

收藏
2020-07-26

共1个答案

小编典典

尝试这样:

$.ajax({
    type: 'POST',
    // make sure you respect the same origin policy with this url:
    // http://en.wikipedia.org/wiki/Same_origin_policy
    url: 'http://nakolesah.ru/',
    data: { 
        'foo': 'bar', 
        'ca$libri': 'no$libri' // <-- the $ sign in the parameter name seems unusual, I would avoid it
    },
    success: function(msg){
        alert('wow' + msg);
    }
});
2020-07-26