Alex Cook schrieb:
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of Yansky
> Subject: [jQuery] Retrieve content from element using AJAX?
>
> Is it possible to retrieve specific content from another page, rather
> than
> the whole page when using AJAX?
>
> -----
>
> Short answer is no, there is no such functionality. You can however
> fudge a few things to make it appear that you are only loading a
> fragment. I had to do something like this recently, so if anyone has a
> better way to do this let me know.
>
> http://pastebin.com/897708
>
> Go look at the code and you'll see what I did was pretty basic. I just
> loaded the page (in this example the .load() function entry from the API
> docs) into a hidden div, created a reference to that div, and then
> pulled out the information I wanted and spit it out via console.log().
> You could easily grab the fragment you wanted from the loaded page and
> pipe it into your display area as desired using the same technique.
>
> Again, if there's a better way, please let me know as this seemed a
> little cumbersome to me but I was unable to figure out a different
> method.
>
> -ALEX
Depends on what you're using in the backend. if you're using Rails you
can easily return whats needed depending on the kind of request:
if request.xml_http_request?
render :layout => false
The same is of course possible with any other backend language. One or
the other framework for PHP has that already build-in, otherwise you can
still do the following:
if ($_REQUEST['X-REQUESTED-WITH'] == 'XmlHttpRequest') {
// It's an Aja request
}
(can't remember if thats the correct syntax for php)
-- Klaus
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/