-3

Edited

I Have edited this to make it abit more clear on what i'm looking for. I have a website that is Built on HTML5 and controlled by CSS3 and Jquery, Because of this all of my sites content is on one page.

When i'm doing an update to my page i want to be able to set an option in a config somewhere so that when users land on my page they are re-directed to another page, a bit like site maintenance page.

When searching on the internet there are lots of ways to create config files but they all seem to relate to .net or flash

As my site is not built on any of these i figured i would have to create my own form of web config, After looking around etc i believe i can achieve this in JQuery.

I currently have the following code for loading an XML file in JQuery

$(document).ready(function()
{
$.ajax({
type: "GET",
url: "jquery_xml.xml",
dataType: "xml",
success: function(xml) { parseXml(xml); }
});
});

I know that from here i need to then search for the Tag in my XML file. This is what i have currently:

function parseXml(xml)
{
//find Website Status
$(xml).find("WebSite").each(function()
{
// This is where i need help
});

I know how to ouput this information if i wanted it to be displayed on a page but im actually looking to see what the website status is. This is the XML file i have.

<?xml version="1.0" encoding="utf-8" ?>
<Webconfig>
<WebSite Status="Live">
</WebSite>
</webconfig>

Hopefully this has made it a bit more clearer.

Regards Bobby

  • possible duplicate of [How can I make a redirect page in jQuery/JavaScript?](http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery-javascript) – Nano Jun 14 '14 at 09:06
  • check this http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery-javascript/21396837#21396837 – Govind Singh Jun 14 '14 at 09:08
  • Thank you for your posts but its not quite as simple as just redirecting people, Redirects are very common so there's loads of posts about this, The bit im struggling to find is jquery reading an XML file, If the XML file contains update when my page loads it displays a different page, if it shows as live it continue's to load the existing content on the page. – user3487006 Jun 14 '14 at 09:19
  • It would be better if you explored the avenue of using PHP to do the redirecting – MarshallOfSound Jun 15 '14 at 02:52
  • This is how i have re-directed in the past but i did not want to just redirect people i wanted a config file that was checked for att and then action if it was set to something, i have managed to figure this this out now and posted an answer, but thank you for taking the time to respond – user3487006 Jun 16 '14 at 07:22

2 Answers2

0
window.location="yourwebpagehere.com/still/being/made.html"

Will redirect your users

MarshallOfSound
  • 2,629
  • 1
  • 20
  • 26
  • Thank you for this suggestion, i have posted an answer detailing what i did to get this to work, i used your suggest for re-direct after figuring the code out to check an XML file. many thanks – user3487006 Jun 16 '14 at 07:21
0

Okay i managed to figure this out now. I'm posting the answer just in case anyone else wants an answer to this.

This is the JQuery Code:

$(function() {

        $.get("data.xml", {}, function(res) {

            var status = $(res).find("SiteStatus");
            console.log("Status = "+status.text());
            if(status.text() == "Update"){
                window.location = "any url you like";
            }
        }, "xml");

});

And the XML file i have looks like this:

<?xml version="1.0" encoding="UTF-8" ?>
<root>
<SiteStatus>Live</SiteStatus>
</root>

Just make sure you got

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

In your HTML page and this will check for status in the XML log. If its set to update it well re-direct to a page if its set to anything else it ignores carry's on the website.