【发布时间】:2011-01-20 04:46:09
【问题描述】:
对 javascript 中的 OOP 完全陌生,但我尽我所能尝试和阅读。
我创建了一个名为 Invoices 的简单测试 JavaScript 类。发票只有两种方法。一种方法触发另一种方法。这部分似乎工作正常。
我的问题在于将数据对象从一种方法转移到另一种方法。我在第一种方法中放置了一个警报,(据我的理解)这个警报应该显示从第二种方法返回的数据......但它不是。
任何帮助将不胜感激。哦.. 我也在使用 jquery。
这是我的密码。
function Invoices()
{
this.siteURL = "http://example.com/";
this.controllerURL = "http://example.com/invoices/";
this.invoiceID = $('input[name="invoiceId"]').val();
}
invoice = new Invoices;
Invoices.prototype.initAdd = function()
{
//load customers json obj
this.customersJSON = invoice.loadCustomers();
alert(this.customersJSON);
//create dropdown
}
Invoices.prototype.loadCustomers = function ()
{
$.post(this.controllerURL + "load_customers"),
function(data)
{
return data;
}
}
【问题讨论】:
标签: javascript jquery oop