Hello and thanks for your help.
I think that i need context, i attach my test file:

from django.shortcuts import render_to_response
from off_bert.offerte.forms import RichiestaForm
from django.http import HttpResponseRedirect

def richiesta(request):
    if request.method == 'POST':
        form = RichiestaForm(request.POST)
        if form.is_valid():
            processo_richiesta()
    else :
        form = RichiestaForm()
        return render_to_response('richiedi.html',{'form': form})

def processo_richiesta():
    from django.template import Template, Context
    t = Template('ciao, {{scritto}}')
    c = Context({"scritto": """script type="text/javascript">
                                               alert("ok")</
script>"""})

    t.render(c)

But don't work

can you tell me some sample to look

Thanks

Luca

On 14 Lug, 20:07, Shawn Milochik <shawn.m...@gmail.com> wrote:
> On Jul 14, 2009, at 12:30 PM,luca72wrote:
>
>
>
> > Hello
> > I have a question in my view fiole i have this
>
> > def myfunct()
> >     do this...........................
> > now i need only to return a js alert message on the same page
> > is it possible?
>
> We need more information. Are you calling myfunct() via an AJAX call?  
> I don't see a request in the argument list, but is that because you  
> left it out, or is this not a "view" function (receives request and  
> returns a response)?
>
> Your function executes server-side, and JavaScript (obviously)  
> executes client-side. Python can't do the alert box, but it can:
>
> 1. Render a template containing the JavaScript.
> 2. Pass the JavaScript text into a templatt, via the Context.
> 3. Return a JSON value via AJAX to the template's JavaScript (you have  
> to bind the handler in the JavaScript, preferably using jQuery for  
> ease-of-use) that passes the message to be used for the alert.
>
> I hope this helps. If not, please send more relevant detail. Pretend  
> you're explaining the problem to someone who has no idea what you're  
> talking about, because we don't.
>
> Shawn
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to