Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angularjs - equal sign in $http post data

I'm using angularjs' $http service to post data to my API. It works great.. until I add and equals sign to the contents of data (JSONRequest in example)

var request = {
    'method': 'POST',
    'url': API_URL + apiActionName,
    'data': JSONRequest,
    'withCredentials': true,
};
$http(request).
success(function(data, status, headers, config) {
    // handle success
}).
error(function(data, status, headers, config) {
    // handle error
}

this works for data contain the following JSONRequest

{
    'text':'this is  some text'
}

however when the data contains this

{
    'text':'this is = some text'
}

the request is escaped and the server cannot do anything with the POST!! It seems to work with all other characters.

Any help would be greatly appreciated! Thanks

like image 744
Aaron Avatar asked Sep 12 '26 18:09

Aaron


1 Answers

I always use JSON.Stringify() for my POST payloads.

like image 137
Jeff Swensen Avatar answered Sep 14 '26 09:09

Jeff Swensen