// Use $(callback) for document ready events, the ready() method is deprecated.
// jQuery CDN
// Effects
// Themeroller
jQuery event.which returns which keyboard key or mouse button was pressed for the event
$("document").ready(function() {
$("#one-button").on("click", getInfoFromServer);
$("#two-button").on("click", getDblFromServer);
$("#three-button").on("click", getXmlFromServer);
});
function getInfoFromServer() {
$.ajax({
type: "GET",
url: "textFromServer.txt",
success: postToPage
});
}
function postToPage(data, status) {
$("#first").text(data);
}
function getDblFromServer() {
$("span").load("getDouble.php",
$("#the-form").serializeArray());
}
function getXmlFromServer() {
$.ajax({
type: "GET",
url: "customer.xml",
datatype: "xml",
success: postToPageTwo
});
}
function postToPageTwo(data) {
$(data).find("customer").each(function() {
let id = $(this).attr("id");
let fName = $(this).find("fName").text();
let lName = $(this).find("lName").text();
let street = $(this).find("street").text();
let city = $(this).find("city").text();
let zip = $(this).find("zip").text();
$('<div class="fName"></div>').html(fName).appendTo('#customers');
$('<div class="lName"></div>').html(lName).appendTo('#customers');
$('<div class="street"></div>').html(street).appendTo('#customers');
$('<div class="city"></div>').html(city).appendTo('#customers');
$('<div class="zip"></div>').html(zip).appendTo('#customers');
});
}
$("#menu").menu({
position: {
my: "center top",
at: "center bottom"
}
});
$("#accordion").accordion({
animate: 1500,
active: 1,
collapsible: true,
event: "click",
heightStyle: "content"
});
$("#tabs").tabs({
event: "click",
show: "fadeIn",
hide: "fadeOut",
active: 3,
collapsible: true,
heightStyle: "auto"
});
$("#dialog").dialog({
draggable: true,
resizable: false,
height: 300,
width: 300,
position: {
my: 'center top',
at: 'center bottom',
of: "#openDialog"
},
show: 1000,
hide: 1000,
autoOpen: false,
buttons: {
"OK": function() {
$("#openDialog").html("You clicked OK");
$(this).dialog("close");
}
}
});
$("#openDialog").click(function() {
$("#customDialog").dialog("open");
});
$("[title]").tooltip();
$("#present").selectmenu({ width: 200 });
$("#btn-3").button();
$("#radio-2").buttonset();
$("#birthday").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "MM dd, yy",
numberOfMonths: 1,
maxDate: 365,
minDate: -3650
});