I am new to Ajax.I found that Ajax will use XMLHTTPRequest. Can any one clarify me the usage of XMLHttpRequest without Ajax and with Ajax with an example.?
How asynchrnous Postback will occur ?
Thanks,
Rakesh.
XMLHTTPRequest is the underlying browser feature that makes what we call AJAX possible, you cannot have one without the other. Postback sounds like a reference to a .Net, which is a completely separate technology to AJAX/XMLHTTPRequest.
Find out more here
Related
In Laravel when we using forms to store or delete a resource, the page is refreshed. What is the best technology to avoid refreshing the page while the request is being processed? AJAX, Vue.js, etc?
There are two main ways to handle http requests: synchronously and asynchronously.
Laravel is a PHP framework and therefore uses... PHP, which is a synchronous language. This implies a page refresh for every requests you make. The point is, every PHP framework have this behavior, this is the way PHP works.
So let's answer your question: indeed, you need an asynchronous technology to make a request to the server and get the response without refreshing the page. The technolodgy of choice in this case is Javascript, which will be able to make AJAX calls.
An AJAX (asynchronous JavaScript and XML) will, as stated in its name, make an asynchronous request. But an AJAX request is just the way of doing it, it's not really a technology. Yes, javascript frameworks like Vue.js are using AJAX, but that is overkill to just make some AJAX requests.
Using Axios or even jQuery is much easier and will allow you to make a request, grab the answer and modify your page without refresh very quickly :)
[EDIT]
The process to achieve what you are looking for is pretty simple:
Use Axios or jQuery to make an AJAX call (an asynchronous request)
Handle this request with Laravel, as you do for every other request
Returns something (or not, it depends of you) to alert your user that something happened
This response will be handled by Javascript
Vue is suitable for small projects where you just want to add a little bit of reactivity, submit a form with AJAX, show the user a modal, display the value of an input as the user is typing, or many other similarly straightforward things. It's scalable and also fantastic for huge project.
This is to ask for verification-- and further info/reference if i'm wrong:
AJAX is the asynchronous go-between between the server and the client-- the operations that
are not bound to loading&reloading the web-pages.
From what i know, it's the class XMLHttpRequest handling all this asynchronousity-- all the methods and members (send(), onreadystatechange, etc.) handling/helping
the asynch operations are on XMLHttpRequest.
is this all in AJAX-- as far as its significant components go?
from what i see, XMLHttpRequest is the only vital thing in AJAX.
am i missing something here?
You are right. XMLHttpRequest is what's really the core of the ajax architecture. In a modern web app, it's most likely to be hidden under the hood ( jQuery or another javascript framework/lib ).
I remember using XMLHttpRequest for my ajax stuff like 5-6 years ago and it wasnt very user friendly but it was working.
Jquery encapsulate the XMLHttpRequest object within some methods, like get and ajax.
These methods also simplify the way the parameters are sent to and received from the server. (xml/json)
The server side part of the ajax operation is not tied to any technology. Which means you can have PHP, C# WCF/ASMX Services or something else to do the server side work.
Have a look at this, this or this for complete references for the XMLHttpRequest object.
I know two ways of submitting form data: by having a button of type submit or by an AJAX post call. What is the difference between those two regarding performace?
This is a very general question, so here is a very general answer.
If you implement the AJAX call efficiently on the server, then you can expect AJAX to be more performant (when measured on the server) than a full page round-trip.
For instance, if you use ASP.NET, clicking a button to submit a page will cause a POST of the form data and a complete re-buildup and rendering of the page. That is not necessary with an AJAX call, if you use real AJAX and not the Microsoft AJAX Control Toolkit for ASP.NET.
Better to use Ajax.BeginForm instead of Html.BeginForm. It will prevent the full postback and will improve the performance.
Ajax POST
Ajax post prevents reload and postback.İt sends data to controller.
Form Data
İt occurs reload page and postback.İt sends data to controller.
I am an average newbie to CakePHP. While reading cookbook found Ajax form and its submission. But it lacks more details.
What are the main difference between ajax form and a normal form or What are the more specific cases we need to use Ajax form over normal form?
An example will be appreciated
Thanks....
A properly implemented Ajax form is exactly the same as a regular form, except that if JavaScript is enabled a submit handler will be bound to it that will prevent the normal submission of the form and send the data using the XMLHttpRequest object. The response will then be processed by JavaScript in the current page instead of by loading an entirely new page.
This isn't necessarily a CakePHP question, it's understanding what AJAX is.
AJAX in layman's terms is basically submitting data to a website without reloading the current page. If this is the sort of feature you want, you'll need to look into the RequestHandler component and the JsHelper in the CakePHP book for the version you are using.
i am using ajax and jsp, but instead of using out.write() in jsp side, i do write the response string into session o object, then i open a colorbox panel and write the session value into page.
is doing this make my site not-ajax?
i understand that using querystring is an other way around, what is the difference between my solution and querystring solution?
thnx
No. AJAX is just a process for letting the client talk to the server without reloading the page. A lot of people think it is all of the dynamic behavior on the page as well, but that's been there before AJAX was first made possible in 2005 when Microsoft added the XMLHttpRequest object to IE.