UPDATED QUESTION
here is my code :
function BillerDetails() {
var iState = _xmlCFHttp.readyState;
var sStatus = "";
if (iState == 4) {
if (_xmlCFHttp.responseXML.xml != "") {
var $accNum = $("#CXACNUM");
var $accNme = $("#CXACNAM");
_xmlCFRecv.loadXML(_xmlCFHttp.responseXML.xml);
sStatus = _xmlCFRecv.selectSingleNode("/result/status").text;
if (sStatus == "1") {
if ($("#CXCLRCD option[value='" + $(this).children("Data1").text() + "']").length == 0) {
$("#CXACNUM").val($("#CXACNUM").val("Data5"));
$("#CXACNAM").val($("#CXACNAM").val("Data4"));
}
} else {
var msg = _xmlCFRecv.selectSingleNode("/result/message").text;
if (msg != "") {
alert(msg);
}
}
}
}
}
Data4 and Data5 is a field inside the database. these need to be display in the textbox. however as previous, it return output at the textbox as below :
Object Object
However when it display, it give me output :
[Object object]
This is because you are setting the returned value of val back to the same input, which is a jquery object
You need to simply do
$("#CXACNUM").val( JSON.stringify( Data5 ) );
尝试使用JSON.stringify
作为
$("#CXACNUM").val(JSON.sringify(Data5));
function BillerDetails() {
var iState = _xmlCFHttp.readyState;
var sStatus = "";
if (iState == 4) {
if (_xmlCFHttp.responseXML.xml != "") {
var $accNum = $("#CXACNUM");
var $accNme = $("#CXACNAM");
_xmlCFRecv.loadXML(_xmlCFHttp.responseXML.xml);
sStatus = _xmlCFRecv.selectSingleNode("/result/status").text;
if (sStatus == "1") {
if ($("#CXCLRCD option[value='" + $(this).children("Data1").text() + "']").length == 0) {
var Data4Val=$(this).children("Data4").text();
var Data5Val=$(this).children("Data5").text();
$("#CXACNUM").val($("#CXACNUM").val(Data5Val));
$("#CXACNAM").val($("#CXACNAM").val(Data4Val));
}
} else {
var msg = _xmlCFRecv.selectSingleNode("/result/message").text;
if (msg != "") {
alert(msg);
}
}
}
}
}
i have updated your code. hope this will work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.