I want to print the audio tag in html what should I add in my html code
<script ></script>
$(document).ready(function()
{
// Request
jQuery.getJSON
(
,
{
prot_vers: 2, cl_login: " ", cl_app: " ", cl_pwd: " ",
req_voice:"heather22k",
req_text:$("#demo_voices_textarea").val()
},
function(data)
{
//api response management
$("#demo1player").html("<audio src='"+data.snd_url+"' controls='controls' />");
}
);
});
and my html code is here
<form name="Test" method="post">
<textarea name="demo_voices_textarea" rows="4" cols="20">Hello World !</textarea>
<br/>
<input type="submit" value="Create sound!">
</form>
many thanks
</div>
Instead of .html() use .text() as shown :-
$("#demo1player").text("<audio src='"+data.snd_url+"' controls='controls' />");
Use <pre>...</pre>
tag
$("#demo1player").html("<pre><audio src='"+data.snd_url+"' controls='controls' /></pre>");
Use <
and >
instead <
and >
:
$("#demo1player").html("<audio src='"+data.snd_url+"' controls='controls' />");
I would use the $(element).text() function. A few days ago I've looked how to escape html in javascript. I found following Link: Escaping HTML strings with jQuery
I think it should work for your purpose.