hi,
i have a function in a controller which queries the database if the user is
logged in and then grabs the information using json (as below)
def pruchaseHistoryJson():
if auth.user:
rows = db(db.sale.auth_id == auth.user.id
).select(db.sale.title,
db.sale.price,
db.sale.shipping_address,
db.sale.shipping_state,
db.sale.shipping_city,
db.sale.shipping_zip_code)
else:
redirect(URL('default', 'user/login'))
import gluon.contrib.simplejson as json
prodHistory = json.dumps([{'name': i.title,
'prodValue':i.price,
'shipAdd':i.shipping_address,
'shipCity':i.shipping_city,
'shipState':i.shipping_state,
'shipCode':i.shipping_zip_code} for i in
rows])
return prodHistory
i am now trying to figure out the $.ajax function so i can display this
result in a view. below is the $.ajax function. i get an error using
firebug stating, invalid request. What do i do to fix this?
<script type="text/javascript">
function testAjax()
{
$.ajax({
type: 'GET',
url:'127.0.0.1:8000/suzannecollins/onlineStore/pruchaseHistoryJson',
data:{prodName: "rows.name", prodCost: "rows.prodValue", prodAdd:
"rows.shipAdd", prodCity: "rows.shipCity", prodState: "rows.shipState",
prodCode: "rows.shipCode"},
dataType: "json",
timeout: 5000,
success: function(msg){
prodHistory = $.parseJSON(msg);
$("#shopProdHistory").html(prodHistory.prodName
+" "+prodHistory.prodCost
+" "+prodHistory.prodAdd
+" "+prodHistory.prodCity
+" "+prodHistory.prodState
+" "+prodHistory.prodCode);}
});
}
</script>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.