Load a section of the webpage without using AJAX technology

I am creating a website and I would like the left menu to remain fixed while loading the content of the clicked option.

Currently, each menu link uses AJAX to return the requested content. Although it works well, I would like to find an alternative to avoid complications with tracking statistics and search engine optimization (Google bots).

Is there a way to achieve a similar effect as seen on http://www.foundcrelamps.com/ without using javascript?

Answer №1

If I were to approach this differently, I would ensure that the links in the menu are valid hyperlinks directing users to specific content. For example, I would link "Contacte" to "http://www.foundcrelamps.com/contacte" so that pasting the URL into a browser will load the page directly.

In addition, I would retain the use of Ajax to prevent the need for reloading the entire page with each click.

One option is to utilize History.js to manage browser history and modify URLs for seamless navigation with Ajax functionality.

To implement this using conventional anchor elements and standard href attributes:

$('a').click(function(){
    $('YOUR CONTAINER').load($(this).attr('href'));
    return false; // prevents loading the entire page
});

On the server side, code similar to the following may be used:

/* AJAX check  */
$isAjax = false;
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest') {
    $isAjax = true;
}

if (!$isAjax) {
    outputHeader();
}

outputMainContent();

if (!$isAjax) {
    outputFooter();
}

This approach allows for loading only the inner content when utilizing Ajax, while loading the entire page when not.

An alternative method involves loading the entire page with jQuery but replacing only the necessary html content.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Python script for launching a .html file and automating the process of clicking the submit button

I am currently working with a .html file where I need to send a value using a submit button. Here is how the code looks: <HTML> <HEAD> <TITLE>ABC Corporation</TITLE> </HEAD> <BODY> <FORM ACTION="http://192.168.2.2/cg ...

Validate whether the datepicker HTML element contains a value before running a jQuery function

I have implemented a jquery datepicker in my form to select dates. In this setup, I am using jquery to check if the selected date is empty and also to verify if it falls on a Sunday. To address the issue of checking if the date is empty, I have utilized t ...

Align elements evenly across the center while maintaining a controlled distance between each one

In my current scenario, I am working with a flexible number of elements ranging from 2 to 5. My goal is to evenly distribute these elements within a div that also has variable width. This task might seem straightforward, but there's a unique twist inv ...

Receiving a 401 error code stating "unauthorized" when attempting to invoke a method using AJAX in .NET

I am working on a .NET project within the framework 4.5.1 When I incorporate ajax as shown below, the debugger successfully hits the page_load event: $.ajax({ "async": true, "crossDomain": true, type: "POST", url: "Advance ...

Update the text input field from a different webpage

I am working with two PHP pages, let's call them page1.php and page2.php. On page1.php, there is a textbox with a default value of 0, while on page2.php, there is a button. I have these two pages open in different tabs in a browser. My goal is to have ...

Two scenarios for tag class and just class are considered in this discussion

FOUND THE SOLUTION. Sending a huge shoutout to @JHeth and @Marko Vucurovic for their invaluable help! This query may seem lengthy, but the concept is straightforward. Let's break it down into 2 scenarios: Scenario I <html> <head><titl ...

Bootstrap is having trouble with aligning flex items and preventing them from wrapping to a new row

I am working on a code implementation that dynamically displays flex items, with each item taking up half of the display width. So, after two items, I need to start a new row. Is there a way to add a line break after every two items displayed on the page ...

What is the best way to enable editing of a form when the edit button is clicked?

I have created a simple profile page where users can edit their profile information. I have placed a button at the end of the page. Initially, the form should be uneditable, but when the button is clicked, the form becomes editable. I attempted to use `dis ...

Tips for positioning a JQuery drop-down correctly

Although I am not well-versed in JQuery and struggle with CSS, I often find myself working with both. Currently, I have encountered a problem: The jquery script I am using involves clicking on an image to reveal a login box that drops down using slideTogg ...

Another problem with CORS again?

My rails application uses the host http://myhost.dev to search for music through the vk.com API. The API provides a search method called audio.search. Below is the code snippet from my search.js.erb file which is executed via a remote link to the search ac ...

Step-by-step guide to create an impressive autocomplete search box with jQuery UI

I'm currently using jQuery UI for autocomplete in my search box. So here's the array that I am passing from the controller to the view, which contains the JS. public function suggest_channel(){ $this->load->library('mcurl&apo ...

Avoid triggering a keydown event if certain div elements have been clicked

When the user presses the space bar, my script is set up to perform certain actions, such as stopping an audio player: $('html').keydown(function(e){ if(e.keyCode == 32){ // Stop the audio player } } However, an issue arises when a ...

Disable a button during an AJAX request

Whenever a button is clicked, the record is saved to the database without refreshing the page using AJAX. I have implemented the AJAX code successfully. Now I need guidance on how to manage the state of the Submit button - enabling/disabling it dynamicall ...

Using jQuery to show each letter individually with a delay

I attempted to split all the letters and display them one by one using a timeout. I came across some solutions, but they don't seem to work for me. With this script, it adds a complete layer (word) but skips over each loop. The message is a string th ...

How to retrieve the value of a table row by clicking with the mouse using jQuery?

I am having an issue with my table data display. Each row in the table is assigned a unique ID, which corresponds to the value of the tr-tag. My goal is to log this ID in the console when a table row is clicked. Here is the table: $.getJSON(`http://local ...

jQuery slide adjusts the width of the slide as it transitions

The script is running smoothly. Check out the jsFiddle here The issue lies in its width adjustment when sliding (clicking "here"). It seems to be cutting off the width related to a 100px margin-left in #slider. Why does it seem to "jump" and how can this ...

Regularly monitoring the existence of a file using AJAX in Django

A new feature has been added to my application built in Django. The feature allows users to input an Elasticsearch query on a form located on the site, which then generates a report for them to download. Everything was running smoothly until we encountered ...

The Django template fails to implement CSS styling

I am trying to apply text-align: justify and reduce the text width on a Django template file, but it seems that my CSS isn't working for only this specific element. I have no idea how to solve this issue even though my static files and direction are f ...

Troubleshoot jQuery in an ASP.NET application

Is there a way to intercept the jQuery function call in my Web app that displays a <div>? I want to identify exactly what triggers the appearance of that <div>. I am looking to display the same div using a different button, but the original bu ...

Tips for efficiently utilizing a datatable in PHP with a substantial amount of data

After successfully implementing the jQuery plugin Datatable, I encountered a new challenge when working with a large dataset of 100000 rows. It takes around 10-15 minutes to load all the data. Can anyone provide suggestions on how to optimize the loading s ...