I need to have the response from php update the html form element by id. I’m using Ajax to submit the form, and upon success it needs to change the value of the html element by ID. How can I make this work? Because right now it does nothing!
$.ajax({
url:"autosave.php?save=true",
method:"POST",
data:{"subject":subject,"body":body},
dataType:"text",
success:function(data)
{
// $('#id').value = this.responseText;
document.getElementsByName('id')[0].value = this.responseText;
$('#autoSave').text("Updated");
}
});
2
Answers
Working Code:
You should try:
(Not tested)