Skip to content

Instantly share code, notes, and snippets.

@marco-mendes
Created March 19, 2016 01:37
Show Gist options
  • Save marco-mendes/b68d3674b259137dfd89 to your computer and use it in GitHub Desktop.
Save marco-mendes/b68d3674b259137dfd89 to your computer and use it in GitHub Desktop.
index.html
<!doctype html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#user-submit').click(function () {
var payload = {
name: $('#user-name').val()
};
$.ajax({
url: "/users",
type: "POST",
contentType: "application/json",
processData: false,
data: JSON.stringify(payload),
complete: function (data) {
$('#output').html(data.responseText);
}
});
});
});
</script>
</head>
<body>
<h3>Entre o nome de um usuario que vai ser gravado no banco de dados MySQL:</h3>
<input id="user-name" type="text" />
<input id="user-submit" type="submit" />
<p id="output"></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment