我创建了一个对象,我想访问该对象中的变量。但是每次我运行它时,testThis 和 whatThis 变量都是未定义的。我不确定为什么会这样。
/* HTML above */
<script type="text/javascript">
var formData;
var dataClickTest;
var FormRowData = function () {
var self = this;
self.someValue = "I am visible. Look Here!";
self.frds = new Array();
self.addRowData = function (ctrlData) {
self.frds.push(ctrlData);
}
self.convertData = function (rowData) {
var hi = rowData[0].attr('data-ctrltypeid');
var hello = "hi";
}
}
function postBackPart(div_id) {
formData = $('#' + div_id).find('input, select').filter('[name*=".InputtedData"]');
var testThis = FormRowData(); /* error here */
var whatThis = testThis.someValue; /* error here */
$.ajax({
url: '/TestEdit/Sections',
type: 'POST',
data: formData,
success: function (result) {
}
});
return false;
}
</script>
</body>
</html>