Reputation: 119
I have to make a request to a pipl.com ( http://apis.pipl.com//search/v2/json/?email=maryuca_alias%40yahoo.com&person_mode=all&exact_name=0&no_sponsored=0&key=myKey) in oder to get some information about a person.The response of this request is a json object. I am not able to do this with a ajax/jquery/jsonp call because their server does not support this types of call. Is there a way to process the response on server side (I use Struts 1) or client side?
If you have a solution ,please answer this question.
<html>
<head>
</head>
<body>
<script type="text/javascript">
function getJSONP(url, success) {
var ud = '_' + +new Date,
script = document.createElement('script'),
head = document.getElementsByTagName('head')[0]
|| document.documentElement;
window[ud] = function(data) {
head.removeChild(script);
alert(data);
success && success(data);
};
script.src = url.replace('callback=?', 'callback=' + ud);
head.appendChild(script);
}
getJSONP('http://apis.pipl.com//search/v2/json/?email=maryuca_alias
%40yahoo.com&person_mode=all&exact_name=0&no_sponsored=0
&key=key&callback=?', function(data){
console.log(data);
});
</script>
</body>
</html>
Upvotes: 0
Views: 236
Reputation: 160181
Use something like HttpClient to make the request from Java, probably in a service called by the action class. That response can be processed by either Java or JavaScript, depending on your needs.
Upvotes: 1
Reputation: 23
ok, it looks like u make a valid cross site request, but u get header different than expected or data not JSON formated?
if its just headers of response are not proper u can always parse data on client side. best way to specify problems would be pasting headers of request, response and code
Upvotes: 0