我得到的錯誤「buildXML沒有定義」當我運行這段代碼:的JavaScript/jQuery的:問題調用對象內部的功能(功能未定義)
var c = {
updateConsumer:function (cid,aid,sid,survey){
var surveyXML = buildSurveyXML(survey);
},
buildSurveyXML: function(survey) {
var surveyResults = survey.split("|");
var surveyXML = '';
for (var i=0;i<surveyResults.length;i++){
...
}
return surveyXML;
}
}
這包括這個HTML JS並調用updateConsumer功能:
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Web Service Test</title>
<meta charset="utf-8">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="../../shared/js/consumerSoap.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
c.insertConsumer("First","Last","55555","[email protected]","76:1139");
});
</script>
</body>
</html>
在'C'你定義了'updateConsumer'和'buildSurveyXML',但你叫'insertConsumer'在你的腳本塊。由此看來,'buildXML'永遠不會被調用。這是正確的代碼/標記嗎? – FishBasketGordo