my skills with jquery core are not that great, though Ive been working with JQuery for almost a year now.So here is the question.
What changes would I need to do , if I want to use XDomainRequest whenever a cross-domain request is made on IE8+?
Basically, I want to make changes to the xhr function for jquery.ajaxSettings object, so that whenever a cross-domain request is made , and the browser is detected as IE8+, the xhr returns a XDR rather than an XHR.
What all pitfalls would I need to keep in mind before I do that?
Any other pointers that anyone would want to give are appreciated.
I know this as a question is very general, but from what I feel, so is the topic of substituting xhr with xdr in the required scenario.
Thanks
You should try the AjaxHook extension.
JQuery doesn't support this natively, but you can hack around it yourself. Here's the original JQuery bug report about this issue:
http://bugs.jquery.com/ticket/8283
That link above has some work around code. Here is a more complete solution:
https://github.com/jaubourg/ajaxHooks/blob/master/src/ajax/xdr.js
Related
I'm trying to support a user base that is tied to IE8 currently and noticed that I can't use the 'DELETE' or 'PUT' verbs. Will using modernizr allow me to do this in IE8? If not what library if any will allow me to do this w/ out a hacky work-around like passing the verb in post data
According to answers to this (old) SO question, you shouldn't have a problem with DELETE and PUT if you use them via the xmlHttpRequest object (ie Ajax calls).
In addition, the Wikipedia page for xmlHttpRequest also states that all the verbs are supported from IE7 upward.
They aren't supported from a straightforward form submission, but there's not really much need to use them in this context; POST should be sufficient. But for Ajax calls, you should be fine.
I recommend trying it in IE8 to confirm, but I don't think you'll have a problem.
Given that, I don't think you'll have a need for Modernizr to help you with this, unless you need IE6 support. But just to be sure, I had a look at the Modernizr docs, where it lists all the feature detections it does, and I couldn't see anything about http verbs. And even if Modernizr did detect it, you'd still need a polyfill to actually fix it, and I don't know of anything that would be able to do that. .... So it's a good thing you probably won't need it, then.
From my understanding, AJAX requires the use of the XMLHttpRequest object. What I am confused on is the source of where the XMLHttpRequest object is connected to? In the school projects, I have connected it to XML and mySQL and was told that I am doing AJAX. What if I connect the XMLHttpRequest object to a PHP script which contains an array of data? Would that count as AJAX?
The reason why I ask is because I was thinking of adding AJAX to my resume, but since this area seems so broad and I have had limited experience with it, I want to make sure I have a clear understanding of this technology.
The AJAX part is just how the request is made from the client. If it happens asynchronously using XmlHttpRequest, it doesn't matter where the request is going :-) It could be a request to an server side script in PHP, a JSON file, an xml file, or anything else.
It's not broad at all. Any time you do an async web request (actually, it doesn't even have to be async, but that's really the best way to to use it) via javascript (rather than through a Form submit) you're using AJAX. What you connect to or what you retrieve is irrelevant.
Without being rude, I'd like to point out that if you state on a resume that you possess "a clear understanding of this technology" then you're not being honest, since you're asking this question, which indicates that your understanding of the technology isn't "clear".
If, however, you're totally confortable with the use of Ajax and were simply not entirely clear on it's lexical definition... well... now you should be.
yes ,the ajax can used for all language,soever java or asp and php
The jQuery AJAX call has a type parameter that allows to specify the method for an async call (GET/POST/PUT/DELETE); documentation states that:
The type of
request to make ("POST" or "GET"),
default is "GET". Note: Other HTTP
request methods, such as PUT and
DELETE, can also be used here, but
they are not supported by all
browsers.
What does this mean for modern browsers? Can I count on jQuery AJAX to make fully RESTful calls, which rely on the PUT and DELETE verbs?
Yes. $.ajax makes the dirty work to allow PUT and DELETE.
Here you'll find more info: Are the PUT, DELETE, HEAD, etc methods available in most web browsers?
I know it's an old question, but I keep on coming here when searching for the browsers HTTP methods support. I never found anything saying exactly which browser supports which call. The link provided is not clear on it too.
Because of that sentence in jQuery manual (they are not supported by all browsers), I've stayed clear for a while of PUT and DELETE and tried to limit myself to GET and POST. However, today I decided to run some tests with IE 6 for a rest API I'm developing and I didn't have any problems to use also DELETE.
If it works in IE6, crappy 2001 technology, it is pretty much likely that it will work everywhere and that sentence on jQuery manual is pretty much obsolete.
I will update this post in the future with further tests. If anyone knows of a browser not supporting ajax calls for PUT and DELETE, I would like to hear.
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.
I recently came across http://chromeexperiments.com/. I found a couple of projects there that are quite intriguing: 100 Tweets and twitterbrowse (I'd post links to them but I'm not yet allowed). These both work fine for me in Firefox 3.5 under Ubuntu 9.04. The thing that I find particularly peculiar is the fact that these two "experiments" seem to issue Ajax requests to other domains than the ones they are hosted on (to twitter.com, more exactly). I have tried the same thing on an HTML5 page (using <!DOCTYPE html>), but I can't get it to work.
I'm using MooTools to create the requests, but that shouldn't be a problem, it's still Ajax, right?
Any idea how those sites are doing this?
XMLHttpRequest Level 2 allows for cross-domain AJAX. Read more about it here.
Have a look at http://snook.ca/archives/javascript/cross_domain_aj/
I personnaly was able to do this using the JSON method on a personal project where I had to receive ajax response from a different domain's server.
They aren't using HTML5 for the ajax request, they're using JSONP which is essentially a getter for JSON, but can be made across any domain