-
Notifications
You must be signed in to change notification settings - Fork 6
/
example2.html
49 lines (49 loc) · 1.34 KB
/
example2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<head>
<title>Submit Form Using AJAX and jQuery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#submit").click(function(){
var text = $("#text").val();
var dataString = 'ptext='+ text;
if(text=='')
{
alert("Please Fill All Fields");
}
else
{
// This code submits the form
$.ajax({
type: "POST",
url: "pollysubmit.php",
data: dataString,
cache: false,
success: function(result){
// Plays the mp3 at the returned URL
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', result);
audioElement.play();
}
});
}
return false;
});
});
</script>
</head>
<body>
<div id="mainform">
<h2>Submit string for polly processing.</h2>
<div id="form">
<h3>Enter you text!</h3>
<div>
<label>Text :</label>
<input id="text" type="text">
<input id="submit" type="button" value="Submit">
</div>
</div>
</div>
</body>
</html>