我試圖將這兩塊拼在一起,我甚至不知道問題出在哪裏,沒有警報()和螢火蟲不告訴我任何東西。django - JSON對jQuery的響應
// django with yellow api to find_business search:
// ----------------------
def get_yellow(request):
mimetype = 'application/json'
yapi = YellowAPI(settings.YELLOW_API_KEY, test_mode=True, format='JSON', handlers=[])
data = yapi.find_business(what='403-253-0395', where='Calgary', uid='127.0.0.1')
print data #I can see here there is a result
return HttpResponse(data,mimetype)
// jQuery
// ----------------------
$(document).ready(function(){
$.getJSON('http://myserver:8000/get_yellow/',
function(data) {
alert('Fetched ' + data.length + ' items!');
})
});
// I'm including a full response on a simple call, is this a valid json?
// ----------------------
{ 「摘要」:{ 「什麼」: 「403-253-0395」, 「裏」: 「卡爾加里」, 「緯度」: 「」, 「東經」: 「」, 「FIRSTLISTING」 :1, 「LASTLISTING」:1, 「totalListings」:1, 「PAGECOUNT」:1, 「當前頁」:1, 「listingsPerPage」:40}, 「目錄」:[{ 「parentId的」: 「」, 「isParent」 :假的, 「距離」: 「」, 「內容」:{ 「視頻」:{ 「果」:假的, 「inMkt」:假}, 「照片」:{ 「果」:假的, 「inMkt」:假} 「資料」:{ 「無濟於事」:假 「inMkt」:假}, 「DspAd」:{ 「無濟於事」:假 「inMkt」:假}, 「URL」:{ 「無濟於事」:假「inMkt 「:」false「,」Logo「:{」avail「:false,」inMkt「:false}},」id「:」1931218「,」name「:」Future Shop「,」address「 「1180-33 Heritage Meadows Way SE」,「city」:「Calgary」,「prov」:「AB」,「pcode」:「T2H3B8」},「geoCode」:{「latitude」:「50.987988」,「 「:」 - 114.04424「}}]}
你Django的主機上運行的JavaScript? – Anders 2011-03-22 14:22:23