<html>
<head>
<title>appcache_display_template</title>
<style type="text/css">
.dialog{
display:none;
}
</style>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
<meta charset="utf-8">
<style>
body { font-size: 62.5%; }
label, input { display:block; }
input.text { margin-bottom:12px; width:95%; padding: .4em; }
fieldset { padding:0; border:0; margin-top:25px; }
h1 { font-size: 1.2em; margin: .6em 0; }
div#users-contain { width: 350px; margin: 20px 0; }
div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
.ui-dialog .ui-state-error { padding: .3em; }
.validateTips { border: 1px solid transparent; padding: 0.3em; }
</style>
<script>
$(function() {
// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 550,
width: 350,
modal: true,
buttons: {
"Create an account": function() {
var bValid = true;
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
/* close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}*/
});
function callAJAX()
{
$.ajax({
url: "url",
dataType: "json",
data: $('#users').serialize(),
contentType: "application/json; charset=utf-8",
success: function(data){
alert(data.employees.length)
alert("success")
},
error: function(e, xhr){
alert("error");
}
});
}
$( "#create-user" )
.button()
.click(function() {
$( "#dialog-form" ).dialog( "open" );
$( "#fname" ).val($( "#fname1" ).val());
$( "#lname" ).val($( "#lname1" ).val());
$( "#email" ).val($( "#email1" ).val());
$( "#zipcode" ).val($( "#zipcode1" ).val());
callAJAX();
});
});
</script>
<body>
<div class="demo">
<div id="dialog-form" title="Create new user">
<p class="validateTips">All form fields are required.</p>
<form id='frm'>
<fieldset>
<label for="name">First Name</label>
<input type="text" name="name" id="fname" class="text ui-widget-content ui-corner-all" />
<label for="email">Email</label>
<input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
<label for="zipcode">Zip Code</label>
<input type="text" name="zipcode" id="zipcode" value="" class="text ui-widget-content ui-corner-all" />
<label for="lname">Last Name</label>
<input type="text" name="lname" id="lname" value="" class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>
</div>
<div id="users-contain" class="ui-widget">
<h1>Existing Users:</h1>
<table id="users" class="ui-widget ui-widget-content">
<thead>
<tr class="ui-widget-header ">
<td>First Name</td><td> <input type="text" name="fname1" id="fname1" /></td>
<td>Last Name</td><td> <input type="text" name="lname1" id="lname1" /></td>
</tr>
</thead>
<thead>
<tr class="ui-widget-header ">
<td>Zip Code</td><td> <input type="text" name="zipcode1" id="zipcode1" /></td>
<td>Email</td><td> <input type="text" name="email1" id="email1" /></td>
</tr>
</thead>
<thead>
<tr class="ui-widget-header ">
<td>SSN</td><td> <input type="text" name="ssn" id="ssn" /></td>
<td>DOB</td><td> <input type="text" name="dob" id="dob" /></td>
</tr>
</thead>
<thead>
<tr class="ui-widget-header ">
<td>Address</td><td><input type="text" name="addr" id="addr" /></td>
<td>City</td><td> <input type="text" name="city" id="city" /></td>
</tr>
</thead>
</table>
</div>
<button id="create-user">Create new user</button>
</div>
</body>
</html>
ASKER
<html>
<head>
<title>appcache_display_template</title>
<style type="text/css">
.dialog{
display:none;
}
</style>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
<meta charset="utf-8">
<style>
body { font-size: 62.5%; }
label, input { display:block; }
input.text { margin-bottom:12px; width:95%; padding: .4em; }
fieldset { padding:0; border:0; margin-top:25px; }
h1 { font-size: 1.2em; margin: .6em 0; }
div#users-contain { width: 350px; margin: 20px 0; }
div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
.ui-dialog .ui-state-error { padding: .3em; }
.validateTips { border: 1px solid transparent; padding: 0.3em; }
</style>
<script>
$(function() {
// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 550,
width: 350,
modal: true,
buttons: {
"Create an account": function() {
var bValid = true;
$.ajax({
url: "url",
dataType: "json",
data: $('#frm').serialize(),
contentType: "application/json; charset=utf-8",
success: function(data){
alert("success")
},
error: function(e, xhr){
alert("error");
}
});
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
/* close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}*/
});
function callAJAX()
{
$.ajax({
url: "url",
dataType: "json",
data: $('#frm2').serialize(),
contentType: "application/json; charset=utf-8",
success: function(data){
alert(data.employees.length)
alert("success")
},
error: function(e, xhr){
alert("error");
}
});
}
$( "#create-user" )
.button()
.click(function() {
$( "#dialog-form" ).dialog( "open" );
$( "#fname" ).val($( "#fname1" ).val());
$( "#lname" ).val($( "#lname1" ).val());
$( "#email" ).val($( "#email1" ).val());
$( "#zipcode" ).val($( "#zipcode1" ).val());
callAJAX();
});
});
</script>
<body>
<div class="demo">
<div id="dialog-form" title="Create new user">
<p class="validateTips">All form fields are required.</p>
<form id='frm'>
<fieldset>
<label for="name">First Name</label>
<input type="text" name="name" id="fname" class="text ui-widget-content ui-corner-all" />
<label for="email">Email</label>
<input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
<label for="zipcode">Zip Code</label>
<input type="text" name="zipcode" id="zipcode" value="" class="text ui-widget-content ui-corner-all" />
<label for="lname">Last Name</label>
<input type="text" name="lname" id="lname" value="" class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>
</div>
<div id="users-contain" class="ui-widget">
<h1>Existing Users:</h1>
<form id='frm2'>
<table id="users" class="ui-widget ui-widget-content">
<thead>
<tr class="ui-widget-header ">
<td>First Name</td><td> <input type="text" name="fname1" id="fname1" /></td>
<td>Last Name</td><td> <input type="text" name="lname1" id="lname1" /></td>
</tr>
</thead>
<thead>
<tr class="ui-widget-header ">
<td>Zip Code</td><td> <input type="text" name="zipcode1" id="zipcode1" /></td>
<td>Email</td><td> <input type="text" name="email1" id="email1" /></td>
</tr>
</thead>
<thead>
<tr class="ui-widget-header ">
<td>SSN</td><td> <input type="text" name="ssn" id="ssn" /></td>
<td>DOB</td><td> <input type="text" name="dob" id="dob" /></td>
</tr>
</thead>
<thead>
<tr class="ui-widget-header ">
<td>Address</td><td><input type="text" name="addr" id="addr" /></td>
<td>City</td><td> <input type="text" name="city" id="city" /></td>
</tr>
</thead>
</table>
</form>
</div>
<button id="create-user">Create new user</button>
</div>
</body>
</html>
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY