Someone answered in my past question and provided me with the code necessary to pull a datetime from a server. All is well it’s just that I don’t know how to execute it! for example, I want to the action to happen on pageload, how can I do that?
here’s the Ajax/JSONP code I was given:
$.ajax({
url: 'http://timeapi.org/utc/now.json',
dataType: 'jsonp'
})
.done(function(response) {
// response = {"dateString":"2012-03-06T02:18:25+00:00"}
console.log(response.dateString);// "2012-03-06T02:18:25+00:00"
});
P.S. does the “$” refer to JQuery? I am not very familiar with this syntax…the $.ajax and the .done?
You definitely have to check out jQuery.
Basically,
$refers to the jQuery object, and.ajax()and.done()are functions which are properties of this object. They can be concatenated by a common technique of returning the jquery-context at the end of each function.Simplified you have something like this:
jQuery.function(parameters).anotherfunction(parameters)You should start with this basic tutorial.