Note that there are some explanatory texts on larger screens.

plurals
  1. POobject not is not JSON serializable
    primarykey
    data
    text
    <p>I am trying to load data from a database into a html page. basically when a user access their profile and clicks on "Purchase History" it should query the database and display all the products the user has purchased. </p> <p>I am trying to do this using ajax and json, but i get an error:</p> <pre><code>TypeError: &lt;gluon.dal.Field object at 0x091CCD90&gt; is not JSON serializable </code></pre> <p>Below is the code:</p> <pre><code>def prodHistoryJson(): productName = db.sale.title productCost = db.sale.price prodShipAdd = db.sale.shipping_address prodShipCity = db.sale.shipping_city prodShipState = db.sale.shipping_state prodShipZipCode = db.sale.shipping_zip_code myproducts = {'prodName':productName, 'cost':productCost, 'shipAdd':prodShipAdd, 'shipCity':prodShipCity, 'shipState':prodShipState, 'shipZipCode':prodShipZipCode} import gluon.contrib.simplejson as json returnData = json.dumps(myproducts) return returnData </code></pre> <p>below is the jquery:</p> <pre><code>$.ajax( { url:'/suzannecollins/onlineStore/prodHistoryJson', data: { message: "Your products purchase history is listed below" }, success: function(msg) { try { myproducts=JSON.parse(msg); } catch(err) { console.log(" error"); } // place returned value in the DOM $('#returnData').html(myproducts.title + myproducts.price + myproducts.shipping_address + myproduct.shipping_state + myproducts.shipping_city + myproducts.shipping_zip_code); } }); </code></pre> <p>what am i doing wrong? I can get this all to work if i just do this in a simpler way where a user hits the purchase_History button and it queries the database and displays the products purchased. How do i do the same thing with the code above?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload