Link to home
Start Free TrialLog in
Avatar of Ralph
RalphFlag for United States of America

asked on

Page not loading correctly via jQuery .load()

Source page is prelist_plan_levels.html, (see attached).
The link in source page:
<a href="/cmdb/public_html/Work/list_plan_levels.html" class="UpDowngrade" data-target="center_body" data-pp="Nov 2015" data-scope="PP" data-updown="UP">25</a>

Open in new window

NOTE that there are 3 of these links in the page, each with different 'data-key="value"' parameters, ALL containing data-target.

Source page .ready() function is review_plan_levels(), containing event catcher
$('body').one( "click", 'a.UpDowngrade', listPlanLevelsClick ) ;

Open in new window

Destination page list_plan_levels.html, (see attached).

JS listPlanLevelsClick() function is also attached.

ISSUES:
I've tried two variations of function listPlanLevelsClick(event), the one shows unsuccessfully tries to rely on 'data-target="blah"', but the page does not load in the designated DIV in my web app.  It loads in the entire window.  (See also index.html.)
When it does load, it will correctly perform the commented-out .DataTable() load.

The other variation of this function is to use the commented-out code to force loading into the DIV I desire.
It does target correctly then, but:
A) The success callback never alerts me (an issue?)
B) More importantly, even with a minimal DataTable() configuration, in the console I'm seeing
Uncaught TypeError: $(...).DataTable is not a function

Open in new window


All the cdn.datatables.net  JS and CSS links were fresh as of last week.  Again, it does load a table w/ data when it incorrectly places it in the entire window.

Add'l confusion but not an issue:
Also, you'll note that I'm using  
$('body').one( "click", 'a.UpDowngrade', listPlanLevelsClick ) ;

Open in new window

rather than .on(), because for some reason, maybe you'll understand why, each failed load (when correctly targeted) would retain the click, because subsequent clicks would repeatedly call listPlanLevelsClick(), once for every prior click.

See also http://plnkr.co/edit/oyaHJhYFT8hrz0UcKPR0?p=preview.  That may help, I believe it's public.

Thank you,
Ralph
prelist_plan_levels.html
list_plan_levels.html
list_plan_levels--.txt
listPlanLevelsClick--.txt
index.html
SOLUTION
Avatar of Kim Walker
Kim Walker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ralph

ASKER

Hi,

I need the data from the link to provide parameters for the AJAX operation once it get to the target page list_plan_levels.html, and using that page's .ready() function to run list_plan_levels().

Is there another way to get the link-embedded data-key="value" data to the .ready() function for /cmdb/public_html/Work/list_plan_levels.html?

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ralph

ASKER

Cool, cool, COOL!

VERY frustrated that I couldn't get a rather simple link to target correctly, or get the targeting right but couldn't get to the destination page w/o errors.  I hope I don't have to face that mystery again.

If this works I'm moving again, after a week of frustration and dozens of failed approaches to troubleshoot.

Thanks!
You are welcome.