Very simple Ajax request taking employee id and returning the user info as HTML dumb.
www.xyz.com there lies a service that give me a list of users which can be accessed from
It returns a json, with a wrapping method like following
If I request this json wrapped in a method like as follows:
Then this is a wrapped json which if loads on my page; will try to invoke a method called callMyMethod. This would be allowed in a
<script src="source"> kind of declaration but would not be allowed otherwise.
So what I can do is as follows
This would allow me to stuff with JSON coming from other domain, which I wouldn't have been able to do otherwise. So; you see how I could achieve a cross domain scripting which would have been a tough nut to crack otherwise.
This is just one of the uses.
Other reasons why someone would do that is:
The usage you have specified in example wouldn't probably serve much purpose; would probably just delay the loading of page if processing by server takes time and instead a async ajax call would be much preferred.