Adding an AJAX call to this Combobox to read through JSON
I'm having problems adding a XHR request to query JSON to my script, I rarely work with either so it's giving me a lot of problems. I know that I will need to query a JS file, and that I will need to select from matches in an array, but I am completely stumped on how to do it. Something else I need to do is count matches each time I fire of a request.
The categories startList is what I am using now, it's not really filled in but I was just trying to get it to work first before I started using JSON. Can anyone help me here?
var categories = [];
categories["startList"] = ["Men","Women"]
categories["Men"] = ["Red","Blue","Multi"];
categories["Red"] = ["Leather","Metal","Ceramic","Plastic"];
categories["Leather"] = ["",""];
categories["Metal"] = ["",""];
categories["Ceramic"] = ["",""];
categories["Plastic"] = ["",""];
categories["Blue"] = ["This","That","Neither"];
categories["Multi"] = ["One","Two","Other"];
categories["Women"] = ["Green","Hot Pink","Multi"];
categories["Green"] = ["Them","Those","Moo"];
categories["Hot Pink"] = ["The","Quick","Brown"];
categories["Multi"] = ["Three","Four","Other"];
var nLists = 6;
function fillSelect(currCat,currList){
var step = Number(currList.name.replace(/\D/g,""));
for (i=step; i
Here is a quick sample of one of the JSON fields I will want to query.
{
"idName": "The Time Teller",
"forGender": "m",
"caseDiameter": 1.5,
"caseThickness": 0.5,
"bandWidth": 0.78,
"itemWeight": 1.44,{
"sku": 155320,{ "color1": "white", "color2": "none", "price": 59.99,
"cat": "29400", "img": "155320-0002-front",
"sku": 155411,{ "color1": "blue", "color2": "none", "price": 59.99,
"cat": "32579", "img": "155411-0005-front",
"sku": 160041,{ "color1": "black", "color2": "pink", "price": 59.99,
"cat": "38404", "img": "160041-0001-front",
},
"specialInformation": [
{
"restrictions": "Available for US customers only."
"detail": "Custom 3 hand Japanese quartz movement.",
"detail": "100 meter molded polycarbonate case.",
"detail": "Hardened mineral crystal.",
"detail": "Locking looper and polycarbonate buckle.",
},
开发者_开发知识库 {
"desc": "Nixon's The Time Teller watch keeps it simpleton with hard case and custom molded polyurethane band."'
}
]
}
You have wrong JSON data. For example the blocks like
{ "color1": "white", "color2": "none", "price": 59.99,
"cat": "29400", "img": "155320-0002-front",
should be replaced to
{ "color1": "white", "color2": "none", "price": 59.99,
"cat": "29400", "img": "155320-0002-front" },
But it in not all errors. I recommend you verify your JSON data in http://www.jsonlint.com/. On http://www.json.org/ you will fnd the description of JSON format.
Here is an example of a possible correct JSON data
{
"idName": "The Time Teller",
"forGender": "m",
"caseDiameter": 1.5,
"caseThickness": 0.5,
"bandWidth": 0.78,
"itemWeight": 1.44,
"items": [
{
"color1": "white",
"color2": "none",
"price": 59.99,
"cat": "29400",
"img": "155320-0002-front",
"sku": 155411
},
{
"color1": "blue",
"color2": "none",
"price": 59.99,
"cat": "32579",
"img": "155411-0005-front",
"sku": 160041
},
{
"color1": "black",
"color2": "pink",
"price": 59.99,
"cat": "38404",
"img": "160041-0001-front",
"sku": 155320
}
],
"specialInformation": {
"restrictions": "Available for US customers only.",
"details": [
"Custom 3 hand Japanese quartz movement.",
"100 meter molded polycarbonate case.",
"Hardened mineral crystal.",
"Locking looper and polycarbonate buckle."
],
"desc": "Nixon's The Time Teller watch keeps it simpleton with hard case and custom molded polyurethane band."
}
}
加载中,请稍侯......
精彩评论