Created
October 1, 2015 21:56
-
-
Save lnaia/4f833b5f0f70bc6eb5ad to your computer and use it in GitHub Desktop.
simple xhr post w/ jquery Raw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>example</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> | |
</head> | |
<body> | |
<br><br><br><br> | |
<div class="container"> | |
<textarea id="text" class="form-control" rows="3"></textarea> | |
<br><br><br><br> | |
<h3>Going to post a XHR with:</h3> | |
<p id="text-content"></p> | |
</div> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> | |
<script> | |
$(function () { | |
$('#text').on('blur', function () { | |
var content = $('#text').val(); | |
$('#text-content').text(content); | |
$.post("/some-backend-page", {data: content}); | |
}) | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment