Jump to content

Is it possible to load a page with jquery that uses javascript?


samoi

Recommended Posts

Hello!

I am developing my personal website!

And I am trying to implement it with JS completely. which means I need the page to be one front end page.

But the back-end pages would be the ones which do the work and calculations!

In other words and more explaination:

I would like to have one "index.php" page that contains only a nav bar which handles the mission.

Once the page load it loads with the content of "home.php" (the landing page) if the "contact" tab is clicked then I would like to load the "ContactMe.php" page content.

I have done this already! but the problem is:

"home.php" uses alot of javascript functions and jquery plug-ins. when I load it, it looks messy that you think the JS is disabled in your machine  :-\

Note: the loading has been done with those methods: .load(), $.ajax! -> same results!

 

The conclusion:

* "home.php"

* "ContactMe.php"

* "About.php"

Is it possible to load those pages in the "index.php" and still have their JS functions function correctly and display as if they were accessed individually?

 

The goal that I am trying to achieve is that I make my whole website for the visitor as "One Page Site"! I am challenging myself with it though!

 

Thank you in advance for your informative posts!

 

 

Please Note that I have only put the <html><head><body> tags in the index.php and removed them from the back-end pages such as home.php, contactme.php and about.php! for that sake that it works correctly! but with no hope!

Link to comment
Share on other sites

Yes, you can include your JS in the index page. In fact, if the index page is where you create the HEAD, then that is the best pace to include your JavaScript includes. Heck, you could even include JavaScript code dynamically, but...

 

I know this is your personal site, but any web developer with any experience would tell you that implementing such a site that relies so heavily on JavaScript is a bad idea. Why not just build your site in PHP or someo other server-side language?

 

 

Link to comment
Share on other sites

Yes, you can include your JS in the index page. In fact, if the index page is where you create the HEAD, then that is the best pace to include your JavaScript includes. Heck, you could even include JavaScript code dynamically, but...

 

I know this is your personal site, but any web developer with any experience would tell you that implementing such a site that relies so heavily on JavaScript is a bad idea. Why not just build your site in PHP or someo other server-side language?

First off, thank you for offering the help (thumb up)  :)

Well, I think I made a mistake in my explanation. Actually it's a bad idea for using JS for the most of the work of course. But I use it for some jquery effects and ajax calls :). also, as you mentioned it's only a personal site, not a real live business project! I would be more careful for that I promise!

 

However, here is a overview about what I have done already before coming here, which I think is the same thing you mention:

Here is the index.php file for example:


<html>
<head>
// includes all CSS files
// includes jQuery framework! 
//includes all my JS custom functions!

<title>INDEX.PHP</title>

// THEN ?
<script type="text/javascript">
$(function(){

            $(".NavBarTab#contact").click(function(){

                   $(".GeneralContent").load('contactme.php');

            });

});
</script>

</head>
<body>

<div class="Navi">
<div class="NavBarTabs">Home</div>
<div class="NavBarTabs" id="contact">Contact me</div>
<div class="NavBarTabs">About</div>
</div>

<div class="GeneralContent">
//content!
</div>

</body>
</html>

 

 

 

And for the contact me:

 

// No <html><head><body> tags at all! nor js codes embedded !

<div id="FormToggle"> // note: toggle which means there is an effect function I made in my index.php imported JS files!

// some elements and events to be clicked to fire an ajax call!
</div>

 

 

That's almost it!

 

I hope it's clear now!

 

Any suggestions?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.