title: jQuery noConflict not working
body: <p>I have the following peice of JavaScript which is going to be referenced from a client's website. It uses jQuery 1.5 so my problem is what if the client already has an instance of jQuery loaded? Or an alternative JavaScript library?</p>
  
  <p>I am using noConflict() to try and work around this but it just doesn't seem to work and I can't work out why. Any help is appreciated</p>
  
  <p>The main issue is that I get an error returned telling me that jQueryMH is undefined, but I am clearly defining it before i even set the interval on the keepAlive function.</p>
  
  <pre><code>var head    = document.getElementsByTagName('head')[0];
  var script  = document.createElement('script');
  script.src  = '//ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js';
  script.type = 'text/javascript';
  script.onload = script.onreadystatechange = function() {
                                                  var jQueryMH = jQuery.noConflict(true);
                                                  setInterval(keepAlive(), 5000);
                                              };
  head.appendChild(script);
  function keepAlive() {
      var mhProtocol      = ((document.location.protocol == "https:") ? "https://" : "http://");
      var randomNumber    = Math.floor(Math.random()*10000);
      var mhVisitorId     = document.cookie.match('mhVisitorId=(.*?)(;|$)');
      var urlParamString  = "";
      if(mhVisitorId) { 
          urlParamString = "&amp;mhVisitorId=" + encodeURIComponent(mhVisitorId[1]); 
      }
      var mhUrl = "www.urlishere.com";
      //var jQueryMH = jQuery.noConflict();
      jQueryMH.ajax({
          url: mhUrl,
          dataType: 'jsonp'
      });
  }
  </code></pre>
  
  <p>Other than this, i have tried setting the noConflict() within the function itself and this works and allows me to reference jQueryMH, but then we have the following problem, probably because it is setting noConflict each time the functions runs (every 5s)</p>
  
  <p>The test page I have set up which externally includes this JS Script already has jQuery 1.8 loaded and then it loads the above script afterwards. So because of my noConflict, i would expect jQueryMH.fn.jquery to return 1.5.0 and jQuery.fn.jquery to return 1.8; however they both return 1.5.0 which means my noConflict is not working as jQuery does not stay as the version 1.8 library already loaded on to the clients website.</p>