Solved

Adapting site to benefit from jQuery

Posted on 2011-02-17
2
378 Views
Last Modified: 2012-05-11

Subject:
Adapting an HTML site to benefit from Ajax & jQuery. (I am a newbie to Ajax/jQuery)

Goal:
To take advantage of the fact that we don't need to reload a page every time we submit from a form.

Context:
This is what it all the pages on site offer as menu choices:

Menu1 --- Menu 2 --- Menu 3 --- Menu 4

Menu 2 has 7 options. These 7 options currently use the same php file and they have a slightly different version of the initial form for the user. I would like to continue centralizing my code.

My Question:
How should I structure my code now that I want to benefit from jQuery given that I would like to not reload the page after it was loaded once - and let every submit thereafter be handled by jQuery?
I know how to have the page not reload from within the forms, but if the user makes another selection from Menu 2 I don't want the page to reload but just modify the form displayed.

Thank you.


0
Comment
Question by:gbeaulac
2 Comments
 
LVL 8

Accepted Solution

by:
rationalboss earned 500 total points
ID: 34917057
What you want is to implement AJAX to your website, it is a technique that you use if you wish to make asynchronous calls to the server. You've chosen a Javascript framework that is easy to understand! :)

Here are tutorials to help you started:
http://viralpatel.net/blogs/2009/04/jquery-ajax-tutorial-example-ajax-jquery-development.html
http://articles.sitepoint.com/print/ajax-jquery
http://php4every1.com/tutorials/jquery-ajax-tutorial/
http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/

These reads are worth it :)
0
 

Expert Comment

by:CodilX
ID: 34917617
I'm not sure exactly what you want, but if you have:

<a href="#" id="option1">Option 1</a>

You add a jQuery onclick event and using $.post or $.get, retrieve information you want and add it to a div:

$('#option1').click('function', ({
  $.get('somefile.php?get=something', function(retrieved_data) {
    $('#some_div').html(retrieved_data);
 }
});
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to show span when clicked on? 10 22
Html Table looping 4 13
parse url to form? 7 12
Javascript the "if condition with Or" 8 17
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question