Wondering if anyone can do a quick demo on Jsfiddle to show how it would work to do the following.
想知道是否有人可以在Jsfiddle上做一个快速演示来展示如何做到以下几点。
Let's say I have a mysql table with columns: product_name, product_price, product_id; I do a mysql select and return the array using an AJAX call. How do I render that on page using Knockout?
假设我有一个包含列的mysql表:product_name,product_price,product_id;我做一个mysql选择并使用AJAX调用返回数组。如何使用Knockout在页面上渲染?
I can do the AJAX call and grab the data. It's returned as an object. I use json_encode in the PHP to return the data back in getJSON call.
我可以进行AJAX调用并获取数据。它作为对象返回。我在PHP中使用json_encode在getJSON调用中返回数据。
What do I do next to render it? That's what I am stuck on. I just want to render a table looping product name, product id, and price.
接下来我该怎么做才能呈现它?这就是我所坚持的。我只想渲染一个循环产品名称,产品ID和价格的表格。
var allData = $.getJSON("ajax.php?request=getresults", data, function(response) {
return (response);
})
Thanks!
1 个解决方案
#1
0
Oh.. I found an example and it works! loading a knockout.js observableArray() from .ajax() call
哦..我找到了一个例子,它的确有效!从.ajax()调用加载knockout.js observableArray()
#1
0
Oh.. I found an example and it works! loading a knockout.js observableArray() from .ajax() call
哦..我找到了一个例子,它的确有效!从.ajax()调用加载knockout.js observableArray()