我有一个javascript回调函数,它会在成功调用时返回值为值的响应。以下是函数的示例
callback: function(response) {
var response : response.reference;
alert('success. transaction ref is ' + response.reference);
}
现在我想在检查响应变量是否为空之后立即将响应传递到下面的表单输入文本中调用回调函数
<form action="" method="post">
<input id="response" type="hidden" value="javascript value"/>
<button id="submit" type="button"> Submit </button>
</form>
答案 0 :(得分:0)
根据您的需要调整它;但核心思想是一样的;
从&#39;隐藏&#39;更改类型属性到&#39;文字&#39;并从响应中设置值;
let response = "someResponse";
if(response != null) {
document.getElementById('response').setAttribute('type','text');
document.getElementById('response').value = response;
}
&#13;
<form action="" method="post">
<input id="response" type="hidden" value="javascript value"/>
<button id="submit" type="button"> Submit </button>
</form>
&#13;