如何让 jQuery $.get 将 json 数据检索存储到类变量行业或产品中?
如果您查看从 $.get 调用到 php 文件返回的数据,那么它确实返回了一个 json 数组,是的,我可以使用这些信息,但对我来说更重要的是存储在全局变量中返回的内容班级简介。
Profile=new Profile("kazie.php");
Profile.getProfile(0123, 'Kayla', 'kayla@email.com');
var Profile = function(php_file){
this.php_file=php_file;
this.serial;
this.industry;
this.product;
//Also need to access scope as well
};
Profile.prototype={
getProfile:function(serial, name, email){
$.get(this.php_file,{action: "retrieve_profile", serial: serial, name: name, email: email},
function (data){ //Return a json array of our new profile
//Data is an array of properties. array("industry"=>"Retail");
//I need to assign these properties to my global variables for
//***How to I get data["industry"] to store in Profile.industry?**
}, "json"
);
}
}