dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: Pass jQuery selection to new page?

Hybrid View

  1. #1
    Join Date
    Jan 2012
    Posts
    3

    Question Pass jQuery selection to new page?

    All,

    How do I "pass" (POST/GET??) a jQuery selection set from one page to another?

    Specifically, I'm talking about passing an XML node, but the process would be the same for passing a <div> tag and its contents, right?
    On the first page, I use jQuery to parse an XML file, then when the user clicks a link, I want to pass a reference to a child XML node (depending on which link they click) to the 2nd page.
    Then, the 2nd page will have some jQuery that will parse the child node.

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    you can only pass strings, not objects like nodes.
    you can use cookies or localStorage to pass strings.
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

  3. #3
    Join Date
    Jan 2012
    Posts
    3
    Quote Originally Posted by rnd me View Post
    you can only pass strings, not objects like nodes.
    you can use cookies or localStorage to pass strings.
    Really? I can only pass strings using GET/POST?
    Can you help me understand these examples from jQuery's Documentation?
    Code:
    //Example: Request the test.php page and send some additional data along (while still ignoring the return results).
    $.post("test.php", { name: "John", time: "2pm" } );
    
    //Example: pass arrays of data to the server (while still ignoring the return results).
    $.post("test.php", { 'choices[]': ["Jon", "Susan"] });
    The first one passes an Object, doesn't it?
    And the second is an array, right?
    So, I imagine if test.php was:

    PHP Code:
    <?php
    echo $choices[1];
    ?>
    The output would be "Susan", right?

  4. #4
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    your code is json, a string version of javascript objects. to me, a jQuery selection is a collection of DOM elements, which cannot be passed over http without converting to a string, such as html code.
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles