Re: JQuery .load() works in production but fails in development
I'm sorry none of us replied sooner; I for one completely missed the
original message.
For the record, you can use request.is_ajax to figure out whether a
request is coming from a js file and make the view behave accordingly.
It's mighty useful in some cases.
Also, have you gone trough the official tutorial? It seems to me there
are a few concepts you should be aware of.
Cheers,
Andre Terra
On 7/1/11, Joe Linoff <jlinoff@gmail.com> wrote:
> Hi Folks:
>
> I figured it out. The idea is NOT to use CGI. It is not needed. Simply use a
> Django WSGI URL to access the python module (in a view) and everything it
> works fine. It as blindingly obvious once I figured it out.
>
> Here is what I did to get it to work:
>
> 1. Added a new URL called '/status/sync' in urls.py:
> url(r'^sync/status/$','status'),
> 2. Added status to my views.py:
> from django.http import HttpResponse
> import datetime
> def sync_status(request):
> now = datetime.datetime.now()
> html = 'now = %s' % (now)
> return HttpResponse(html)
> 3. Changed my index.html javascript as follows:
> $('#status').load('/employees/sync/status');
>
> And everything worked perfectly in both environments. I have now removed the
> CGI stuff.
>
> Sorry to have bothered you.
>
> Regards,
>
> Joe
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/nSUGnywpdngJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
--
Sent from my mobile device
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home