|
|
|
The General Ajax Interview Questions consists the most frequently asked
questions in Ajax. This list of 100+ questions guage your familiarity with
the Ajax platform. The q&a have been collected over a period of time
from various blogs, forums and other similar Php sites
|
2. Ajax Interview Questions Part[2]
|
| 2.1 Which
request is better with AJAX, Get or Post?
|
| 2.2 Is the
server or the client in control in AJAX?
|
| 2.3 Does Java
have support for Comet style server-side push?
|
| 2.4 Who’s
Using Ajax ?
|
| 2.5 Is it
possible to set session variables from javascript?
|
| 2.6 What do I
need to know to create my own AJAX functionality?
|
| 2.7 Do I
really need to learn JavaScript?
|
| 2.8 What is
the difference between proxied and proxyless calls?
|
| 2.9 Should I
use XML or text, JavaScript, or HTML as a return type?
|
| 2.10 Are
there any frameworks available to help speedup development with AJAX?
|
| 2.11 11 Is
Adaptive Path selling Ajax components or trademarking the name? Where can I
download it?
|
| 2.12 Should
I use an HTTP GET or POST for my AJAX calls?
|
| 2.13 How do
I debug JavaScript?
|
| 2.14 How do
I provide internationalized AJAX interactions
|
| 2.15 Are
Ajax applications easier to develop than traditional web applications?
|
| 2.16 Whats
with the -alpha in the install instructions?
|
| 2.17 How do
I test my AJAX code?
|
| 2.18 What
exactly is the W3C DOM?
|
| 2.19 When
will HTML_AJAX have a stable release?
|
| 2.20 20What
parts of the HTML_AJAX API are stable?
|
2.1 Which request is better with AJAX, Get or Post?
|
|
AJAX requests should use an HTTP GET request while retrieving data where the
data does not change for a given URL requested. An HTTP POST should be used
when state is updated on the server. This is in line with HTTP idempotency
recommendations and is highly recommended for a consistent web application
architecture.
|
2.2 Is the server or the client in control in AJAX?
|
|
It depends. With AJAX the answer is more in between. Control can be more
centralized in a server-side component or as a mix of client-side and
server-side controllers.
Centralized server-side controller - When having a more centralized
controller the key is to make sure the data in client-side page is in sync with
that of the server. Some applications may keep all the state on the server and
push all updates to client DOM via a simple JavaScript controller.
Client and server-side controllers - This architecture would use
JavaScript to do all presentation related control, event processing, page
manipulation, and rendering of model data on the client. The server-side would
be responsible for things such as business logic and pushing updated model data
to the client. In this case the server would not have intimate knowledge of the
presentation short of the initial page that would be sent to the client page
request. There are some use cases where an entire AJAX application can be
written in a single page. Keep in mind if you choose this type of architecture
that navigation and bookmarking should be considered.
|
2.3 Does Java have support for Comet style server-side push?
|
|
Current AJAX applications use polling to communicate changes data between the
server and client. Some applications, such as chat applications, stock tickers,
or score boards require more immediate notifications of updates to the client.
Comet is an event based low latency server side push for AJAX applications.
Comet communication keeps one of the two connections available to the browser
open to continously communicate events from the server to the client.
|
2.4 Who is Using Ajax ?
|
|
Google is making a huge investment in developing the Ajax approach. All of the
major products Google has introduced over the last year — Orkut, Gmail, the
latest beta version of Google Groups, Google Suggest, and Google Maps — are
Ajax applications. (For more on the technical nuts and bolts of these Ajax
implementations, check out these excellent analyses of Gmail, Google Suggest,
and Google Maps.) Others are following suit: many of the features that people
love in Flickr depend on Ajax, and Amazon’s A9.com search engine applies
similar techniques. These projects demonstrate that Ajax is not only
technically sound, but also practical for real-world applications. This isn’t
another technology that only works in a laboratory. And Ajax applications can
be any size, from the very simple, single-function Google Suggest to the very
complex and sophisticated Google Maps. At Adaptive Path, we’ve been doing our
own work with Ajax over the last several months, and we’re realizing we’ve only
scratched the surface of the rich interaction and responsiveness that Ajax
applications can provide. Ajax is an important development for Web
applications, and its importance is only going to grow. And because there are
so many developers out there who already know how to use these technologies, we
expect to see many more organizations following Google’s lead in reaping the
competitive advantage Ajax provides. Moving Forward The biggest challenges in
creating Ajax applications are not technical. The core Ajax technologies are
mature, stable, and well understood. Instead, the challenges are for the
designers of these applications: to forget what we think we know about the
limitations of the Web, and begin to imagine a wider, richer range of
possibilities
|
2.5 Is it possible to set session variables from javascript?
|
|
It's not possible to set any session variables directly from javascript as it
is purely a client side technology. You can use AJAX though to asyncronously...
Cannot parse XML generated by JSP I am generating an XML using JSP, when i run
the JSP in IE it shows the XML as per DOM, but when i try to parse it using
Javascript , the command xmldoc.documentElement... This is working code I am
using, it might help you. if (!isIE) xmldoc = req.responseXML; else { //IE does
not take the responseXML as...
|
2.6 What do I need to know to create my own AJAX functionality?
|
|
If you plan not to reuse and existing AJAX component here are some of the
things you will need to know. Plan to learn Dynamic HTML (DHTML), the
technology that is the foundation for AJAX. DHTML enables browser-base real
time interaction between a user and a web page. DHTML is the combination of
JavaScript, the Document Object Model (DOM) and Cascading Style Sheets (CSS). *
JavaScript - JavaScript is a loosely typed object based scripting language
supported by all major browsers and essential for AJAX interactions. JavaScript
in a page is called when an event in a page occurs such as a page load, a mouse
click, or a key press in a form element. * DOM - An API for accessing and
manipulating structured documents. In most cases DOM represent the structure of
XML and HTML documents. * CSS - Allows you to define the presentation of a page
such as fonts, colors, sizes, and positioning. CSS allow for a clear separation
of the presentation from the content and may be changed programmatically by
JavaScript. Understanding the basic request/response nature of HTTP is also
important. Many subtle bugs can result if you ignore the differences between
the GET and OIst methods when configuring an XMLHttpRequest and HTTP response
codes when processing callbacks. JavaScript is the client-side glue, in a
sense. JavaScript is used to create the XMLHttpRequest Object and trigger the
asynchronous call. JavaScript is used to parse the returned content. JavaScript
is used to analyze the returned data and process returned messages. JavaScript
is used to inject the new content into the HTML using the DOM API and to modify
the CSS.
|
2.7 Do I really need to learn JavaScript?
|
|
Basically yes if you plan to develop new AJAX functionality for your web
application. On the other hand, JSF components and component libraries can
abstract the details of JavaScript, DOM and CSS. These components can generate
the necessary artifacts to make AJAX interactions possible. Visual tools such
as Java Studio Creator may also use AJAX enabled JSF components to create
applications, shielding the tool developer from many of the details of AJAX. If
you plan to develop your own JSF components or wire the events of components
together in a tool it is important that you have a basic understanding of
JavaScript. There are client-side JavaScript libraries (discussed below) that
you can call from your in page JavaScript that abstract browser differences.
Object Hierarchy and Inheritance in JavaScript is a great resource for a Java
developer to learn about JavaScript objects.
|
2.8 What is the difference between proxied and proxyless calls?
|
|
Proxied calls are made through stub objects that mimic your PHP classes on the
JavaScript side. E.g., the helloworld class from the Hello World example.
Proxyless calls are made using utility javascript functions like
HTML_AJAX.replace() and HTML_AJAX.append().
|
2.9 Should I use XML or text, JavaScript, or HTML as a return type?
|
|
It depends. Clearly the 'X' in AJAX stands for XML, but several AJAX proponents
are quick to point out that nothing in AJAX, per se, precludes using other
types of payload, such as, JavaScript, HTML, or plain text. * XML - Web
Services and AJAX seem made for one another. You can use client-side API's for
downloading and parsing the XML content from RESTful Web Services. (However be
mindful with some SOAP based Web Services architectures the payloads can get
quite large and complex, and therefore may be inappropriate with AJAX
techniqes.) * Plain Text - In this case server-generated text may be injected
into a document or evaluated by client-side logic. * JavaScript - This is an
extension to the plain text case with the exception that a server-side
component passes a fragment of JavaScript including JavaScript object
declarations. Using the JavaScript eval() function you can then create the
objects on the client. JavaScript Object Notation (JSON), which is a JavaScript
object based data exchange specification, relies on this technique. * HTML -
Injecting server-generated HTML fragments directly into a document is generally
a very effective AJAX technique. However, it can be complicated keeping the
server-side component in sync with what is displayed on the client. Mashup is a
popular term for creating a completely new web application by combining the
content from disparate Web Services and other online API's. A good example of a
mashup is housingmaps.com which graphically combines housing want-ads from
craiglist.org and maps from maps.google.com.
|
2.10 Are there any frameworks available to help speedup development with AJAX?
|
|
There are several browser-side frameworks available, each with their own
uniqueness...
|
2.11 Is Adaptive Path selling Ajax components or trademarking the name? Where
can I download it?
|
|
Ajax isn’t something you can download. It’s an approach — a way of thinking
about the architecture of web applications using certain technologies. Neither
the Ajax name nor the approach are proprietary to Adaptive Path.
|
2.12 Should I use an HTTP GET or POST for my AJAX calls?
|
|
AJAX requests should use an HTTP GET request when retrieving data where the
data will not change for a given request URL. An HTTP POST should be used when
state is updated on the server. This is in line with HTTP idempotency
recommendations and is highly recommended for a consistent web application
architecture.
|
2.13 How do I debug JavaScript?
|
|
There are not that many tools out there that will support both client-side and
server-side debugging. I am certain this will change as AJAX applications
proliferate. I currently do my client-side and server-side debugging
separately. Below is some information on the client-side debuggers on some of
the commonly used browsers. * Firefox/Mozilla/Netscape - Have a built in
debugger Venkman which can be helpful but there is a Firefox add on known as
FireBug which provides all the information and AJAX developer would ever need
including the ability to inspect the browser DOM, console access to the
JavaScript runtime in the browser, and the ability to see the HTTP requests and
responses (including those made by an XMLHttpRequest). I tend to develop my
applications initially on Firefox using Firebug then venture out to the other
browsers. * Safari - Has a debugger which needs to be enabled. See the Safari
FAQ for details. * Internet Explorer - There is MSDN Documentation on debugging
JavaScript. A developer toolbar for Internet Explorer may also be helpful.
While debuggers help a common technique knowing as "Alert Debugging" may be
used. In this case you place "alert()" function calls inline much like you
would a System.out.println. While a little primitive it works for most basic
cases. Some frameworks such as Dojo provide APIs for tracking debug statements.
|
2.14 How do I provide internationalized AJAX interactions?
|
|
Just because you are using XML does not mean you can properly send and receive
localized content using AJAX requests. To provide internationalized AJAX
components you need to do the following: * Set the charset of the page to an
encoding that is supported by your target languages. I tend to use UTF-8
because it covers the most languages. The following meta declaration in a
HTML/JSP page will set the content type: * In the page JavaScript make sure to
encode any parameters sent to the server. JavaScript provides the escape()
function which returns Unicode escape strings in which localized text will
appear in hexadecimal format. For more details on JavaScript encoding see
Comparing escape(), encodeURI(), and encodeURIComponent(). * On the server-side
component set the character encoding using the
HttpServletRequest.setCharacterEncoding() method. Before you access the
localized parameter using the HttpServletRequest.getParameter() call. In the
case of UTF this would be request.setCharactherEncoding("UTF-8");. A
server-side component returning AJAX responses needs to set the encoding of the
response to the same encoding used in the page.
response.setContentType("text/xml;charset=;UTF-8");
response.getWriter().write("
invalid "); For more information on using AJAX with Java
Enterprise Edition technologies see AJAX and Internationalization and for
developing multi-lingual applications see Developing Multilingual Web
Applications Using JavaServer Pages Technology.
|
2.15 Are Ajax applications easier to develop than traditional web applications?
|
|
Not necessarily. Ajax applications inevitably involve running complex
JavaScript code on the client. Making that complex code efficient and bug-free
is not a task to be taken lightly, and better development tools and frameworks
will be needed to help us meet that challenge.
|
2.16 Whats with the -alpha in the install instructions?
|
|
HTML_AJAX hasn't had a stable release yet and the pear installer doesn't
install non stable packages by default unless you specify a version.
|
2.17 How do I test my AJAX code?
|
|
There is a port of JUnit for client-side JavaScript called JsUnit
|
2.18 What exactly is the W3C DOM?
|
|
The W3C Document Object Model (DOM) is defined by the W3C as the following: The
Document Object Model is a platform- and language-neutral interface...
|
2.19 When will HTML_AJAX have a stable release?
|
|
Once all the major features are complete and the API has been tested, the
roadmap gives an idea of whats left to be done.
|
2.20 What parts of the HTML_AJAX API are stable?
|
|
We don't have a list right now, but most of the API is stable as of 0.3.0.
There should be no major changes at this point, though there will be lots of
new additions.
|
|