开发者

Jquery ajax() error : "Uncaught Syntax error, unrecognized expression: %2Cacpitool%2Caide"

I have a error when I tried to send post data with ajax() method.

I have a array with :

  • acpitool
  • aide

I use encodeURIComponent() for passing the array with data: but the ajax method fail.

Could you help me?

Thanks

Edit :开发者_如何转开发

This is the ajax call

    $.ajax({
    url: 'AjaxSearch.php',
    dataType: 'json',
    data: param+"="+package,
    type: 'POST',
    success: function(data) {
    }
});

package is a Array like this :

var package = new array("acpitool","aide");

Sometimes, I have this :

var package = new array("bonnie++");

For both, I have an error :

Uncaught Syntax error, unrecognized expression: +


$.ajax({
   url: 'AjaxSearch.php',
   dataType: 'json',
   data: {
      param:  $.param(package);
   }
   type: 'POST',
   success: function(data) {
   }
});

use jQuerys .param() method to serialize an array.

Description: Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.

update based on your comment, try this

data: {
      param:  package.join(',');
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜