My knowledge about javascript is very low; thus, this is a simple question. I have a simple jQuery Ajax function as
$(document).ready(function(){
$('#txtValue').keyup(function(event){
if(event.which == 13){
sendValue($(this).val());
}
});
});
function sendValue(str){
$.post("test.php",{ sendValue: str },
function(data){
$('#display').html(data.returnValue);
}, "json");
}
This sends the json response to with id=”display”
<input type="text" name="txtValue" value="" id="txtValue">
<div id="display"></div>
But instead I want to put the json response as value of another INPUT element in a different form as
<form method="get" action="result.php">
<input id="DISPLAY" type="text" name="something" value="" />
<input type="submit" value="Submit" />
</form>
I want to put json response to and instead of
If you want to put return value to input, you need to use
.val(data.returnValue)instead of.html(data.returnValue)