Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
Showing 21-23 of 23 total

Custom Ajax.Request Function

// this is a custom function that simplifies creating an ajax object

function(url, complete, form, params) {
  params = params ? $H(params).toQueryString() : '';
  if (!complete) complete = function(r){};
  if (form)      params   = Form.serialize(form) + '&' + params;
  new Ajax.Request(url, 
    { asynchronous:true,
      evalScripts:true, 
      onComplete: function(r) { complete(r.responseText); },
      parameters:params
    });
}

Increase the number of simultaneous XmlHttpRequests in Firefox

Firefox doesn't do a lot of simultaneous AJAX (or any kind of HTTP) requests. IE caps it at 2, too. This will allow you to test your XHR overload scripts, or just load pages faster in general.

1. Go to "about:config"
2. Find and edit the following
* network.http.pipelining=false
* network.http.pipelining.maxrequests=4
* network.http.proxy.pipeline=false
3. Make the false's true; I set my maxrequests at 20

Simple DIV Toggle Javascript

// description of your code here

function simpletogglediv(whichLayer)
{
         var theElementStyle = document.getElementById(whichLayer); 

        if(theElementStyle.style.display == "block")
        { 
                theElementStyle.style.display = "none";  
                 
        }
        else
        { 
                theElementStyle.style.display = "block"; 
        }
} 

« Newer Snippets
Older Snippets »
Showing 21-23 of 23 total