0

Right here we go I might have this completely wrong.

I'm working in Wordpress.

On a page I'm creating a html select menu (Main menu) with options that relate to each page in the site. This menu is displayed on the page.

I'm also creating select menus with options for each page (Page Menus), these menu's aren't displayed but stored in a php variable.

The options in the Main Menu relate to these php variable which are the Page Menus

Now when an option is selected in Main menu I would like to load the related Page Menu but I don't want to relaod the page.

Can I store the HTML code for the Page Menus then load them with AJAX when the related option is selected in the Main Menu.

Hope this makes sense and someone can help.

2 Answers 2

1

Follow this example:

<section>
</section>
<div>
    <ul>
        <li data-url="ExternalPage1.php">
            Option 1
        </li>
        <li data-url="ExternalPage2.php">
            Option 2
        </li>
    </ul>
</div>

Using

jQuery

Use this javascript:

$('li').bind('click', function() {
    $('section').load( $(this).data('url') );
});

Hope this help.

Pablo.

Sign up to request clarification or add additional context in comments.

Comments

1

if you are using jQuery: the best way to do this is

$("#menuContainer").load("mymenu01.php")

see http://api.jquery.com/load/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.