User Tools

Site Tools


jquery:allgemein

jQuery

eigene Selektoren erstellen wie hier

$.extend(
$.expr[":"], {
	hottie: ("jQuery( a ).attr( 'rel' ) == 'girl' && " + "jQuery( a ).attr( 'hotness' ) >= 9")
});
 
function FindHotties() {
	$("ol a:hottie").css("font-weight", "bold");
}

HTML5 - Detect geolocation

// ASK GOOGLE FOR COUNTRY'S SHORT_NAME
if (navigator.geolocation) {
	navigator.geolocation.getCurrentPosition(function(position) {
		$.getJSON('http://maps.googleapis.com/maps/api/geocode/json', {
			latlng: position.coords.latitude + ',' + position.coords.longitude,
			sensor: false,
			type: 'JSON'
		}, function(result) {
			var countryKey = result.results[0].address_components[5].short_name;
			console.log(countryKey);
			alert('ITs AMAZING! LOOK AT THIS = ' + countryKey);
		});
	});
}

AJAX post request

$.ajax({
	dataType: "json",
	type: "post",
	url: "file.php",
	data: "id=5&BigBoobies=true",
	success: function(data) {
		// SQUEEZE OUT DATA
		console.log(data);
	}
});

AJAX form post

$("#idForm").submit(function() {
    var uri = "index.php";
    $.ajax({
           type: "POST",
           url: uri,
           data: $("#form").serialize(),
           success: function(data) {
               alert(data);
           }
         });
    return false; // avoid to execute the actual submit of the form.
});
jquery/allgemein.txt · Last modified: 2014/04/09 14:16 by admin