chrisvee
asked on
retrieve json response through javascript
I want to retrieve json response through jquery.
code demo
the above code retrieves all data.
But what to do if i want to retrieve only value of second or hour or minute?
$.getJSON("http://json-time.appspot.com/time.json?callback=?", function(data){
$.each(data, function(key, value){
document.write(key+": "+value+"<br />");
});
});
code demo
the above code retrieves all data.
But what to do if i want to retrieve only value of second or hour or minute?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you very much.
how to log the time exactly when request sent to json and log the time after it arrives.
i want to calculate the time interval between request started and value obtained.
how to log the time exactly when request sent to json and log the time after it arrives.
i want to calculate the time interval between request started and value obtained.
a new question perhaps?
ASKER
may be. but it is related.
window.a = new Date();
$.getJSON("http://json-time.appspot.com/time.json?callback=?", function(data){
window.b = new Date();
$.each(data, function(key, value){
document.write(key+": "+value+"<br />");
});
var c = window.b - window.a;
alert(c);
//$.post("saveDiff.php", {diff:c}); // send difference to server side
});
hope that help...
ASKER
at least guide me how to send a parameter along with json url and get its value back.
i want to data parameter along with json url
and i want the time var back to me as hour,minute,second.
how to get that time() back to me after passing with json url ?
$.getJSON("http://json-time.appspot.com/time.json?callback=?", function(data){
document.write(data["hour"]+":"+data["minute"]+":"+data["second"]);
});
i want to data parameter along with json url
http://json-time.appspot.com/time.json?callback=time()
and i want the time var back to me as hour,minute,second.
function time(){
return (new Date()).getTime()
{
$.getJSON("http://json-time.appspot.com/time.json?callback="+time(), function(data){
document.write(data["hour"]+":"+data["minute"]+":"+data["second"]);
});
how to get that time() back to me after passing with json url ?
ASKER
i mean