Difference between Ajax and Jquery-Ajax [closed] - ajax

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
hi i am new to ajax and jquery. i found many tutorials about ajax and jquery. but what is the difference between Ajax and JQuery ajax? which should i learn? please answer. Thank you

AJAX
AJAX = Asynchronous JavaScript and XML.
AJAX is a technique for creating fast and dynamic web pages.
AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.
Classic web pages, (which do not use AJAX) must reload the entire page if the content should change.
JQUERY
JQuery is a lightweight, "write less, do more", JavaScript library.
The purpose of jQuery is to make it much easier to use JavaScript on your website.
jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.
jQuery also simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation.
So you can code in Jquery very easily wherever you need a AJAX technique
Content from W3SCHOOLS

javascript is a script language, jquery is more like a framework, which is build with javascript. i would recommend, before you start to learn Jquery, you should learn the basics of javascript.

They actually do the same thing: they perform an ajax call.
A very very simple definition is: it is a paradigm of programming that allows you to get or post some data in an asynchronous way. An example would be for example for update a small portion of a website instead of reload the entire page.
An extensive resource about Ajax can be found here: https://developer.mozilla.org/en/docs/Ajax
jQuery ajax (API) is very easy to use and it provides you all you need for keeo going with your work. Anyways if you are curious, I will suggest you to explore the "plain" javascript ajax call, it is interesting.

Related

How to recognise an ajax application?

How can I decide if a website is using Ajax technology? What are the characteristics that I should I look in the website to tell it is an ajax application?
Search the javascript for XMLHttpRequest. Beyond that, the working definition of Ajax is rather too broad to look for, say, specific behaviours.
You can just look into the javascript source code and search for .ajax, .post and .get . If you find any of these they use ajax technologies.
You can also look at the network requests a page sends, if the page sends requests after loading the full page without you seeing it refreshing it probably uses ajax.
There's nothing special about websites using AJAX, it just means they make an asynchronous call to the server at some point. You can't know for certain that the website will make such a call unless you run it.

Beginner looking for suggestion: building my first website with GAE, picking framework and looking for AJAX learning resources [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have zero web programming experience but has been in IT industry for a while, mainly as a CRM technical consultant. I'm familiar with VBScript and Javascript, not in a Web context but as general scripting tools. I'm good at designing business processes, database models and using DB queries. I have some basic understanding of GAE and Python by doing the tutorials by Google. I used to write some tools with C# and VB6 a long time ago.
So I've decided to build my first website on Google AppEngine, and I'm lost in so many choices and new skills to learn.
What I'm planning to build is a simple website where users can post short messages and vote upon them. Which requires a simple but dynamic front page, login/cookie handling, Reddit like post voting/aging and some data storage.
Maybe the first question is which framework should I use? I heard Flask is good for beginner to learn web programming and webapp2 is easy to start since it's integrated to GAE by default. I've looked at Django as well, it looks very powerful, but I couldn't decide.
Since my idea is largely based on a concise but dynamic front page, I guess something AJAX is a must. But I have no clue on where to start. All those Ajax, Jquery, ProtoRPC are so confusing. Which technologies should I use and where can I find good tutorials?
I am also looking for suggestions on potential challenges and anything I should learn to achieve my goal. Thanks!
Since your project is inspired by reddit, the web development course with Steve Huffman (the technical founder of reddit) will be extremely helpful for you.
https://www.udacity.com/course/cs253 - it's free if you just watch the courseware. He even explains their aging algorithms in the end.
This course covers the back-end side of building a python applicaiton with the default webapp2 framework on appengine. He doesn't cover the front-end besides the basics (HTML forms and tables, stuff like this).
Now, Jquery is a Javascript library which is used by about all of the dynamic websites. It is a convenient way to work with the DOM on the fly. Everything you can do with jQuery, you can do with plain javascript, it's just that jQuery is infinitely easier to work with.
This library is used on the front-end, and it doesn't matter what backend you choose. It is extremely simple and powerful and you can learn the basics at the free codeschool course try.jquery.com.
Basically, if you want something to happen on the page dynamically (the arrow becomes red once the user clicked on it), you use jQuery.
AJAX is asynchronous communication with the server, it can be done by plain javascript but jQuery provides a very convenient wrapper for doing it. Usecase: the user clicked on the arrow, you painted it in red with jQuery, you incremented the votes counter (again with jQuery), and now you need to send the upvote to the server without reloading the page. For this you perform jQuery.ajax() call, and pass the user data as a param.
So to wrap it up: you need to write javascript to make a dynamic page and jQuery is the most common library that helps you with this. You need AJAX to get and post data to the server without page refreshes, this is implemented in jQuery. You can use jQuery with any back-end framework that you choose. Start with the simple jQuery tutorial, then read about $.ajax call and it will be clear for you.

What *exactly* is AJAX? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I know what AJAX stands for. I know javascript passably well. But frankly I'm just not clear on what AJAX is.
Because all I know about it is XMLHttpRequest(), but it must be so much more than that. Can someone give a clearer explanation of how AJAX isn't just a certain aspect of perfectly ordinary JavaScript? I can't see how it's anything different.
EDIT: I also understand that it allows you to update a page without reloading. That's fantastic, I know. But I still don't see how that's anything more than standard JavaScript.
Well it's not as if it's magic or something. It really is ordinary Javascript, and it's ordinary XML (or JSON, or some other data format). And it runs in a browser. None of this is particularly new or novel. Microsoft was talking about "DHTML" in 1996, and officially released it in 1997.
But combining these existing things, is an approach that is common enough and useful enough to have earned a specific name. AJAX refers to
the pattern of using asynchronous requests, driven in Javascript logic running in the browser, to retrieve data in XML format or otherwise. Typically the retrieved data is then used to update the HTML page in some way, without causing a full page refresh.
You said you don't see how that's anything more than standard JavaScript.
Using Javascript in a browser you could do something as simple as run a timer that pops up an alert after it expires. Or you could perform a fadeout on a background color. Or do jQuery effects like accordion popouts. Or dynamically sort an HTML table by different columns. Even autocomplete in textboxes is possible using Javascript. These all cause the UI to be updated, but they don't necessarily retrieve any data. (in some cases autocomplete will do so, but not generally).
AJAX always involves communication and data retrieval, so it is distinct from "standard Javascript".
I think to gain an understanding you have to look into where the XMLHttpRequest came from. It was not a standard part of JavaScript at the time. You could not make asynchronous HTTP requests from the browser with pure JavaScript. The XMLHttpRequest object was first introduced by Microsoft in IE5 as an ActiveX control. So with that in mind, the way we use JavaScript today has evolved from a much simpler scenario.
I suggest you read the Wikipedia page - particularly the history section. There's nothing overtly fabulous about Ajax, it was just a coined term for what was at the time a new way of doing things, and it's stuck.
http://en.wikipedia.org/wiki/AJAX
In particular read the definitive article http://www.adaptivepath.com/ideas/ajax-new-approach-web-applications - this is probably the best way to understand where Ajax came from and indeed what it actually means. Probably most importantly
Defining Ajax
Ajax isn’t a technology. It’s really several technologies, each
flourishing in its own right, coming together in powerful new ways.
Ajax incorporates:
standards-based presentation using XHTML and CSS;
dynamic display and interaction using the Document Object Model;
data interchange and manipulation using XML and XSLT;
asynchronous data retrieval using XMLHttpRequest;
and JavaScript binding everything together.
As noted, the exact definition of Ajax is quite hard to pinpoint these days. The methodologies are prone to updating themselves as the browser evolves, but these were the underlying principles at its conception.
"Asynchronous Javascript and XML" -- you're right, it's really just a component of Javascript. From the server side, it's literally nothing: the server doesn't know or care whether it's fielding an AJAX request or a "normal" request (although of course the web application would know and care). It just happens to be famous and have a fancy acronym, because it's very useful in designing web sites.
EDIT: definition from the W3 spec http://www.w3.org/TR/XMLHttpRequest/:
The XMLHttpRequest specification defines an API that provides scripted client functionality for transferring data between a client and a server.
JavaScript happens on the client-side. Ajax uses javascript to receive a REMOTE response from the server without loading the page.
It's a way of getting and sending data from and to the server asynchronously without refreshing the page. Data exchanged used to be just XML (the "X" in AJAX), can now be other things (e.g. JSON or even JSONP).

How do we do AJAX programming

I have no idea about AJAX programming features. I just know that it is Asynchronous Javascript and XML.
Please help me in knowing about this language.
I have gone through many AJAX tutorials. But none of the programs are running. Why I don't know.
Do we save the file with .HTML extension?
Read:
AJAX Tutorial by W3Schools.
AJAX Programming by Google Code University
To start coding you can get the Ajax Control Toolkit by Microsoft. You should read Ajax Control Toolkit Tutorials to get a grasp of it.
You can use the free Microsoft Visual Web Developer 2010 Express Edition as your IDE.
Aside from the correct responses that the others gave you, judging from your question I think you first need to learn about client-side and server-side code.
Do we save the file with .HTML extension?
Yes and no. You will have an HTML frontend, that for instance contains a button. This will be interpreted from the client's (=user) browser. In fact it may be rendered differently depending on the browser/OS/etc.
Now, you attach some Javascript code to this button. This also runs on the client's browser, and creates a XMLHttpRequest object, either directly or through the use of a library (JQuery & Co.). Note that a library is not necessary to do an AJAX request. It will make your life easier if you do a lot of AJAX calls, but it is not essential.
And here's where the magic happens: the XMLHttpRequest object will call asynchronously (i.e.: without reloading the page) a server-side page. This may be a PHP, ASP, Perl etc etc file that does something on the server, for instance queries a database. This part of the operation is absolutely independent from the client. The user can close the browser before the server-side code finishes to load and the server will not know about it.
Once the server-side code has finished executing it returns to the client with some response data (e.g. a piece of XML, JSON, HTML or whatever you like). Finally the client executes (or not) some other Javascript code in response to this, for example to write on the screen, again with no reloading of the page, something based on what the server has returned.
Maybe I can help you understand AJAX by clarifying the concepts a bit.
Please help me in knowing about this language.
AJAX is not a language, it is a way of using existing techniques to improve the user experience of a web site. The language is Javascript in the browser but you can use any server side technique that you feel comfortable with (ASP.NET, Java, PHP, Ruby etc.)
Do we save the file with .HTML extension?
Well, that is not really the point. What you have to grasp here is that there is a server and a browser that interact with each other. Yes, you can use static HTML files for your pages (and save them as .html files), but you'll need a server to respond to the requests of the browser. This may be why your sample code is not working; you need to set up a server that works with your pages.
The whole idea behind AJAX is to improve the user experience by not reloading the entire page when a user interacts with it. You request the data you need and update the page by using Javascript to update the HTML. This is called an out-of-band or asynchronous request.
I just know that it is Asynchronous Javascript and XML.
That is what the acronym stands for but it doesn't quite cover what the technique is for, nor is it accurate any more. In the beginning XML was used to transfer data from the server to the client. People found that XML is not really that easy to work with in Javascript so now it's more common to use JSON. JSON is a snippet of javascript that can be evaluated in the browser. The snippet creates javascript object(s) that represent the data.
If you use a Javascript library, like others have suggested here, you won't have to worry about many of the details though.
Before you get into AJAX you should make sure that you understand:
HTML and CSS
Javascript
how to modify HTML with Javascript
how a browser requests information from a server
how to handle requests on the server
If you are not comfortable with all of these concepts, stick with 'regular' web pages and try to improve your knowledge step by step.
Once you get the basic knowledge from W3school, I suggest you use a framework. Usually developers do not use XMLHttpRequest at all. Instead, javascript frameworks like ExtJS, jQuery and other frameworks make your work simple. I suggest you learn bit of javascript as well. check out jQuery.
Just to add that AJAX is rarely used in its pure form with XMLHttpRequest. You will often use it as a part of AJAX UI libraries which make your life easier. If you are from the Java world - such an AJAX library is Richfaces.
Instead of worrying about how to do AJAX, use something that allows you to forget about it. Frameworks like NOLOH do AJAX (and Comet) for you automatically without you having to do a thing. Just concentrate on your application, and business logic and it does the rest.
Really, everything is done via AJAX if available, automatically. No work on your part. If you're don't want to spend much time researching it, check out this short video that was demonstrated at Confoo PHP Conference this past March http://www.youtube.com/phpframework#p/u/11/cdD9hSuq7aw.
For all those worried about, well, if it's all AJAX, what about search engines? No need to worry, http://dev.noloh.com/#/articles/Search-Engine-Friendly/.
So instead of having to worry about all these different technologies, or the client-server relationship, you can sit down, code and have your website/WebApp working in no time.
You can read about NOLOH is this month's cover story of php|architect magazine, http://www.phparch.com/magazine/2010/may/.
Enjoy.
Disclaimer: I'm a co-founder of NOLOH.
It is easy one. Ajax getting data from server side by client side execution. We have to do use XMLHttpRequest to get the result.

ajax and jsp integration

I want to capture the responseXML that i have built in my jsp.
What should I do.
after that i will transform it in html.
I know this is annoying and we could do it with a framework or a library like jquery but i realize it with ajax.
Also i have problems with jquery and jsp\servlet since i must use a JSON SERVICE.
Why it seems to me that is so complicated.
It doesn't need to be that complicated. You maybe just need to align all the technologies out one by one yourself. JSP, Servlet, JavaScript, HTML DOM, HTML and Ajax are all separate technologies which needs to be learnt and understood separately. Trying everything together at once without understanding them separately will indeed likely lead to more confusion, complication and frustation as you encountered. Follow the given links to learn about them separately. Learn walking before running or cycling.
The jQuery library just removes the need to write/duplicate all the code to keep it all crossbrowser compatible. Only executing an Ajax request the crossbrowser way is already far over 10 lines of (well-writen/indented) code. jQuery brings it to an minimum, an oneliner is possible.
To learn more about the wall between JavaScript/Ajax and Java/JSP/Servlet, you may find this article useful. I've posted several answers before how to get JSP/Servlet/Ajax to work together (although in combination with JSON and jQuery, but almost everyone will agree that JSON and jQuery are the way to go; JSON is easy to generate/parse in Java using Google Gson and is easy to build/access/process in JavaScript as it is the language's own nature; jQuery is actually a revolution in the way you use JavaScript). Here's a good starting point to find code examples I posted before.
Hope this helps.

Resources