MQ.Util Class
Utility class to aid MQ Leaflet plugins
Methods
cacheBust
()
private
Function will return a string that is used in URL's indicate the server when the cache should and should not be used. example usage: var url = "http://url?cacheBust=" + MQ.IO.cacheBust();
doGetJSON
-
url
-
ioSettings
-
callback
Performs an HTTP GET of the given URL, returning the results as a JSON object to the callback.
Return value: The return value is a cancel function. If invoked, the request is cancelled.
The callback function takes one arg (the JSON response) on success. On failure, it takes arguments (false, errorInfo). errorInfo may be null and varies by the type of request made with ioSettings.
doJSONP
-
url
-
ioSettings
Injects a script tag into the dom with the src as the given url. It is intended to be used with services that support a callback param in the url, so that async calls can be done without cross-site domain security restrictions.
doJSONV
-
url
-
ioSettings
-
callback
Injects a script tag into the dom with the src as the given url. This is intended to be used with services that inject a varible into the dom as a result of the request. (GasPrices)
doPostJSON
-
url
-
requestObj
-
ioSettings
-
callback
Similar to doGetJSON but posts the request, serializing and sending the given requestObj as the post data. The content type is set to application/json
doXhr
-
url
-
ioSettings
-
xhrCallback
Perform an XHR get with the given URL and settings. The callback takes the parameters (xhr, errorInfo). errorInfo is an object if an error happened and is undefined/false if success. Returns an abort function.
Parameters:
Returns <Function>
an abort function
indexOf
-
haystack
-
needle
-
start
deal with fact that ie8 doesn't support indexOf
Returns <Number>
parseJSON
-
jsonText
Parse JSON and return the resultant value. Return undefined on failure.
Parameters:
-
jsonText
Stringthe text that we want to convert to an object
Returns <Object>
the js object
quote
-
string
If the string contains no control characters, no quote characters, and no backslash characters, then we can safely slap some quotes around it. Otherwise we must also replace the offending characters with safe escape sequences.
Parameters:
-
string
Object
Returns <String>
the object converted to a string and wrapped in quotes
str
-
key
-
holder
Produce a string based on the passed in variables
Parameters:
Returns <String>
the objects value converted to a string
stringifyJSON
-
obj
The stringifyJSON method takes a value and returns as JSON text.
Parameters:
-
obj
Object
Returns <String>
the json string representing the object
toQueryString
-
obj
Convert all non-default fields of the object to a query string format.
Parameters:
-
obj
Objectconverts the object to a url query string
Returns <String>
the query string
xhr
()
XMLHttpRequest | ActiveXObject
private
Create and return an XMLHttpRequest object