views:

1194

answers:

2

I have a webservice that when called without specifying a callback will return a JSON string using application/json as the content type.

When a callback is specified it will wrap the JSON string in a callback function, so it's not really valid JSON anymore. My question is, should I serve it as application/javascript in this case or still use application/json?

+11  A: 

Use application/javascript, that way clients can rely on the content-type without having to manually check whether a response has padding or not.

John Millikin
+2  A: 

Use application/json as per rfc4627.txt if what you return is plain json.

If you return javascript, then use application/javascript as per rfc4329.txt

Florian Bösch