i was playing with this idea - here's what i came up with: #found this
snippet via google
in my javascript (included into the base.html):
function refreshResults(){
var xhr = new XMLHttpRequest();
xhr.open("GET", "/list/);
xhr.onreadystatechange = function(){
if(xhr.status == 200){
document.getElementById("results").innerHTML =
xhr.responseText;
}
}
}
inside the code.py:
class list: #just made something to build me a list to pass in
def GET(self):
import os
path="/home/gmilby/public_html/ajax_webpy/sessions/"
here
dirList=os.listdir(path)
stuff = []
for fname in dirList:
stuff.append(fname)
return render.list(stuff)
list.html:
$def with (stuff):
<li>$stuff</li>
neat idea - wish it worked :)
On Jul 5, 7:51 am, Branko Vukelic <[email protected]> wrote:
> On Mon, Jul 5, 2010 at 1:19 PM, Greg Milby <[email protected]> wrote:
> > i've been wondering if webpy can use XMLHttpRequest - we need a search
> > function on webpy.org - i do not see anything like this in the site
>
> Whole point of XMLHttpRequest is that it's an xml *HTTP* request. So
> anything that can handle HTTP requests (GET, POST) can handle
> XMLHttpRequest. Just handle it as regular HTTP request with a special
> header. Here's an example:
>
> obj._is_ajax = web.ctx.env.get('HTTP_X_REQUESTED_WITH')
>
> --
> Branko Vukelić
>
> [email protected]
> [email protected]
>
> Check out my blog:http://www.brankovukelic.com/
> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca:http://identi.ca/foxbunny
>
> Gimp Brushmakers Guildhttp://bit.ly/gbg-group
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.