Replaced endsWith and each with vanilla js equivalents

Step one into making bind work with only jQuery or prototype
Make bind work with only jQuery without prototype if needed

If jQuery is included before as an adjunct and jQuery is the
 implementation behind $; the jQuery.ajax call will be used.
 If neither is included earlier then prototype will be used.

 jQuery doesn't have a "to JSON string" function so JSON.stringify
 is used and to secure older browsers the json2 script is included.