Jump to content

Scripting


trinistorm
 Share

Recommended Posts

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

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

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

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

Meh, the most popular feature of jQuery is probably the $() CSS-notation-style DOM traversal function.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...