Skip to content

Instantly share code, notes, and snippets.

@Bodacious
Created January 21, 2011 20:24
Show Gist options
  • Save Bodacious/790346 to your computer and use it in GitHub Desktop.
Save Bodacious/790346 to your computer and use it in GitHub Desktop.
This is a demo of how you can notify "THE BIG 4" when your xml sitemap has been updated
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Sitemap example</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
var googleUrl = "www.google.com/webmasters/sitemaps/ping?sitemap=";
var yahooUrl = "http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=APPNAMEHERE&url=";
var bingUrl = "http://www.bing.com/webmaster/ping.aspx?siteMap=";
var askUrl = "http://submissions.ask.comping?sitemap=";
var sitemapUrl = "http://gavinmorrice.com/sitemap.xml"
var urls = [googleUrl, yahooUrl, bingUrl, askUrl];
jQuery(function(){
jQuery.each(urls, function(index, url){
jQuery.get(url + sitemapUrl, function(data, textStatus, XMLHttpRequest){
// add optional callback here or just get rid of the function
alert(url + " was " + textStatus);
});
});
});
</script>
</head>
<body>
<!-- page -->
</body>
</html>
// assuming jQuery is already loaded...
// set variables
var googleUrl = "www.google.com/webmasters/sitemaps/ping?sitemap=";
var yahooUrl = "http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=APPNAMEHERE&url=";
var bingUrl = "http://www.bing.com/webmaster/ping.aspx?siteMap=";
var askUrl = "http://submissions.ask.comping?sitemap=";
// your sitemap url goes here
var sitemapUrl = "http://gavinmorrice.com/sitemap.xml"
// stick all urls in an array
var urls = [googleUrl, yahooUrl, bingUrl, askUrl];
// when the document is ready...
$(function(){
// for each search engine url...
jQuery.each(urls, function(index, url){
// ping the search engine url and do something with their request (optional)
jQuery.get(url + sitemapUrl, function(data, textStatus, XMLHttpRequest){
// add optional callback here or just get rid of the function parameter
alert(url + " was " + textStatus);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment