Ajax的官方定义为Asynchronous JavaScript and XML,即是依赖于现有的XML/CSS/HTML/JavaScript来提供可交互性更好的网页应用的技术方案。Ajax并不是新的技术规范,其中最核心的依赖可以认为就是XMLHTTPRequest对象,这个对象使得浏览器可以发出HTTP请求与接收HTTP响应。
路径与参数
functiongetParameterByName(name,url){if(!url)url=window.location.href;name=name.replace(/[\[\]]/g,"\\$&");varregex=newRegExp("[?&]"+name+"(=([^&#]*)|&|#|$)"),results=regex.exec(url);if(!results)returnnull;if(!results[2])return"";returndecodeURIComponent(results[2].replace(/\+/g," "));}// 使用方式如下// query string: ?foo=lorem&bar=&bazvarfoo=getParameterByName("foo");// "lorem"varbar=getParameterByName("bar");// "" (present with empty value)varbaz=getParameterByName("baz");// "" (present with no value)varqux=getParameterByName("qux");// null (absent)