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?
ThanksEdit :开发者_如何转开发
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(',');
}
精彩评论