trinistorm Posted January 28, 2010 Share Posted January 28, 2010 I about to pick up website scripting to improve my web pages and i would like to know where is easier to start strict jquery, javascript or Ajax? Link to comment Share on other sites More sharing options...
Ingolme Posted January 28, 2010 Share Posted January 28, 2010 Forget jQuery and AJAX. They just make use of Javascript.You have to learn Javascript first. And you would probably do well learning HTML DOM and XML DOM too, before you try jQuery or AJAX. Link to comment Share on other sites More sharing options...
Synook Posted January 28, 2010 Share Posted January 28, 2010 jQuery and AJAX are both just technologies involving JavaScript. jQuery is a framework, AJAX is a technique involving JavaScript's XMLHttpRequest object.Edit: Ingolme got there first. Link to comment Share on other sites More sharing options...
trinistorm Posted January 28, 2010 Author Share Posted January 28, 2010 So if were to view ajax or jq docs i would see the same basic constructs just more use of classes and objects etc? Link to comment Share on other sites More sharing options...
justsomeguy Posted January 29, 2010 Share Posted January 29, 2010 Basically. Javascript is a pretty funky language. Look at these examples: var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)var loadedobjects=""var rootdomain="http://"+window.location.hostnamevar bustcacheparameter=""function ajaxpage(url, containerid){ var page_request = false if (window.XMLHttpRequest) // if Mozilla, Safari etc page_request = new XMLHttpRequest() else if (window.ActiveXObject){ // if IE try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else return false page_request.onreadystatechange=function(){ loadpage(page_request, containerid) } if (bustcachevar) //if bust caching of external page bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', url+bustcacheparameter, true) page_request.send(null)}function loadpage(page_request, containerid){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) document.getElementById(containerid).innerHTML=page_request.responseText}function loadobjs(){ if (!document.getElementById) return for (i=0; i<arguments.length; i++){ var file=arguments[i] var fileref="" if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding if (file.indexOf(".js")!=-1){ //If object is a js file fileref=document.createElement('script') fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", file); } else if (file.indexOf(".css")!=-1){ //If object is a css file fileref=document.createElement("link") fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", file); } } if (fileref!=""){ document.getElementsByTagName("head").item(0).appendChild(fileref) loadedobjects+=file+" " //Remember this object as being already added to page } }}ajaxpage('feeds.php', 'feeds'); $("#feeds").load("feeds.php", {}, function(){ alert("The feed has been loaded"); }); Ext.Ajax.request({ url: 'feeds.php', success: function(response, opts) { var obj = Ext.decode(response.responseText); Ext.get('feeds').update(obj.data); }, failure: function(response, opts) { alert('server-side failure with status code ' + response.status); }}); The first example is native Javascript code that doesn't rely on any external libraries. The second uses the jQuery library, and the last uses the ExtJS library. Those examples look fairly different, the first is just procedural code and the last two are object-oriented examples which use JSON structures to pass data around. All three of those are doing basically the same thing, sending an ajax request to load content into an element on the page.When you learn Javascript you'll learn the procedural way at first. When you take on a library like jQuery or ExtJS you'll need to learn how they do things, but you'll still be able to use everything you already learned about Javascript. So there's still learning to do if you want to start using a library, but you'll already need to know how to use Javascript in order to use the libraries. Link to comment Share on other sites More sharing options...
trinistorm Posted January 29, 2010 Author Share Posted January 29, 2010 Thank you. I can see why jquery is so popular. Good use of oop. Link to comment Share on other sites More sharing options...
Synook Posted January 29, 2010 Share Posted January 29, 2010 Meh, the most popular feature of jQuery is probably the $() CSS-notation-style DOM traversal function. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.