Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

jQuery getJSON Output using Python/Django -


so, i'm trying make simple call using jquery .getjson local web server using python/django serve requests. address being used is:

http://localhost:8000/api/0.1/tonight-mobile.json?callback=jsonp1290277462296 

i'm trying write simple web view can access url , return json packet result (worried actual element values/layout later).

here's simple attempt @ alerting/returning data:

$.getjson("http://localhost:8000/api/0.1/tonight-mobile.json&callback=?", function(json){     alert(json);     <!--$.each(json.items, function(i,item){     });--> }); 

i able access url directly, either @ http://localhost:8000/api/0.1/tonight-mobile.json or http://localhost:8000/api/0.1/tonight-mobile.json&callback=jsonp1290277462296 , get valid json packet... i'm assuming it's in noob javascript:)

my views.py function generating response looks follows:

def tonight_mobile(request):     callback = request.get.get('callback=?', '')          def with_rank(rank, place):         return (rank > 0)      place_data = dict(         places = [make_mobile_place_dict(request, p) p in place.objects.all()]     )      xml_bytes = json.dumps(place_data)     xml_bytes = callback + '(' + xml_bytes + ');'      return httpresponse(xml_bytes, mimetype="application/json") 

with corresponding urls.py configuration:

(r'^tonight-mobile.json','iphone_api.views.tonight_mobile'), 

i still confused on how use callbacks, maybe issue lies. note able call directly 'blah.json' file giving me response, not through wired url. assist me direction?

first, callback = request.get.get('callback=?', '') won't value of callback.

callback = request.get.get( 'callback', none )  

works better.

to debug kind of thing. might want include print statements in django view function can see what's going on. example: print repr(request.get) helpful thing put in view function can see dictionary.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -