Wednesday, July 29, 2009

[jQuery] Re: Advice needed on jQuery page to be built

just seen Brian's solution, which is similar but cleaner, don't know why
I didn't think of just leaving the data in the href.

Liam Potter wrote:
> Hi gnet,
>
> I've not really done much with arrays, so this is more theory but you
> should be able to build upon it.
>
> You will need a separate file, that you will be sending the ajax
> requests to, and the html it returns should be printed in the divs
> using the success callback on the ajax method.
>
> first, you need to echo the array as links, and have the id set as the
> array key then the javascript would be something like
>
> $("a.array").click(function(){
> var arrayKey = $(this).attr("id");
>
> $.ajax({
> type: "POST",
> url: "arrays.php",
> data: "arrKey="+arrayKey,
> success: function(html){
> $("div.result").append(html);
> }
> });
> });
>
> Like I said, no idea if this would work, as I don't have a lot of
> experience with arrays, but see what you can do with it.
>
> - Liam
>
> gnetcon wrote:
>> Liam:
>>
>> Thanks for the feedback!
>>
>> I have my page built, with the array created and it populates my
>> second pane
>> fine with data from the first array item (1 of 100). What I'm having
>> difficulty wrapping my brain around is how to update the second div,
>> passing
>> an array key to re-populate the div w/out reloading the page. Is that
>> possible? OR do I need to have a separate page that would accept the
>> key
>> and simply return the HTML to display in the contents of that div?
>>
>> Example:
>>
>> If a user selected the 5th row of data in pane #1, I then need to update
>> pane #2/3 with the data from the PHP array key of 4 ($arrXML[4]).
>>
>> TIA!
>>
>>
>> Liam Potter wrote:
>>
>>> divs, updated using ajax.
>>>
>>>
>>
>>

No comments: