Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Submit whatever value is entered into text field via AJAX
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>AJAX demo</title>
<input type="text" id="myTextField" />
<button id="ajax">Submit AJAX request</button>
<script src=""></script>
$("#ajax").on("click", function(){
var text = $("#myTextField").text();
type: "POST",
url: "submit.php",
cache: false,
data: { "value" : text },
success: function(response){
alert("The server says: " + response);
error: function(response){
alert ("Ajax Error");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment