Location: PHPKode > projects > ezStats for XBOX Live > ezStats2_xbl/admin/templates/addplayer.html
<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
		(function($) {
			$.extend({
				add_player: function() {
					// Daten aus Inputfeldern extrahieren
					var elements = $('#addplayer input:not(:radio), #addplayer input:radio:checked, #addplayer select');
					if (elements.length) {
						var input = {};
						for (var i = 0; i < elements.length; i++) {
							input[elements.eq(i).attr('name')] = elements.eq(i).val();
						}
					} else input = "";
					
					// AJAX starten
					$.ajax({
						type:     "POST",
						url:      "action.php",
						dataType: "json",
						data: {
							input: input,
							sid: "$sid",
							action: $('#addplayer .button').attr("href")
						},
						error: function(data) {
							if (data && data.responseText)
								$('aside').text("").html(data.responseText).fadeIn();
						},
						success: function(data) {
							// Ergebnis ausgeben
							if (data && data.message) {
								$('aside').stop(true, true).hide().text(data.message).fadeIn().delay(2000).fadeOut();
								$('#name').val("").focus();
							}
							
							// Weiterleiten, falls Parameter uebergeben wurde
							if (data && data.href) document.location.href = data.href;
							
							// Spieleruebersicht aktualisieren, falls Funktion geladen wurde
							if ($.getUrlVar('sid')) $.load_player();
						}
					});
				}
			});
		})(jQuery);
		
		$('#addplayer .button').click(function(e) {
			e.preventDefault();
			$.add_player();
		});
		
		
		$('#name').keypress(function(e) {
			if (e.which == 13) $.add_player();
		});
	});
</script>

<section id="addplayer">
	<h1>%add_player%</h1>
	<table class="noborder">
		<tbody>
			<tr>
				<td class="tleft"><input type="text" name="name" id="name" size="120" placeholder="%enter_player_here%" value="" /></td>
				<td class="tright"><a href="add_player" class="button">%add_player%</a></td>
			</tr>
		</tbody>
	</table>
</section>
Return current item: ezStats for XBOX Live