1

i got service which makes an ajax call (GET).

var _getMemeValues = function(category_id, attribute_id) {
    return $http.get('/api/meme_​values?category_id='+category_id +'&​attribute_id='+attribute_id);
};

When i make that call the url get encoded like this. http://localhost:8080/api/meme_%E2%80%8Bvalues?category_id=MLB1468&%E2%80%8Battribute_id=MLB1234

How can i solve this? I Tried converting it with toString(), decodeURIComponent but it didn't work

3 Answers 3

1

There is a control character(LRM) in your string

'/api/meme_​values?category_id='+category_id +'&​attribute_id='
here       ^                         and here ^

i.e after meme_ and before attribute_id= just remove it and you'll be fine.
This character usually comes from editors like ms word.

Sign up to request clarification or add additional context in comments.

Comments

1

It seems you should refactor the api or services to use the standard format like this:

'/api/meme_category_id/' + category_id + '/​meme_attribute_id/' + attribute_id

or to be more standard:
'/api/category/' + category_id + '/​attribute/' + attribute_id

and then call as usual in angularjs

function getMeme(categoryId, attributeId) {
 return $http.get('http://localhost/api/category/' + categoryId + '/attribute/' + attributeId);
};

Comments

0

encodeURIComponent is probably what you're looking for:

var someString = "Höe#äe sdfhlen3";
console.log("before: ", someString);
console.log("after : ", encodeURIComponent(someString))

edit: decodeURIComponent is exactly the opposite, trying to decode a URI-encoded string.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.