Search code examples
ajaxxmlhttprequestpyramid

How to change only a part of web page? (is there a non JS solution?)


Hi I'm pretty new to web applications, and I want to make a small form that search for an object and show the results there. I don't want to load the whole web page, probably change only one <div> tag.

Is there a way to do this without Javascript? (It's not mandatory that I don't. Just checking if I can)

I'm using Pyramid framework (and has been working with less than 2-3 days, so please be patient with your answers).

Please point me in the right direction, I feel like I don't even know what to search for.

(Didn't go anywhere with my pyramid XMLHTTPRequest google search).

Thanks a bunch.


Solution

  • No, that's what AJAX is, a Javascript technique. You cannot initiate a XMLHTTPRequest from your browser without it.

    Just use jQuery to load a URL from you Pyramid server; have one route serve up a HTML snippet instead of a full page:

    $('div#somediv').load('http://serveraddress/route/to/snippet')
    

    and jQuery will request /route/to/snippet from your server, and place the result wholesale under <div id="somediv"></div>.