AJAX and XMLHttpRequest Object
HTML-код
- Опубликовано: 10 сен 2024
- AJAX stands for Asynchronous JavaScript And XML.
AJAX is not a programming language, but it is a set of existing web technologies.
AJAX helps in fetching data asynchronously from a remote web server.
When the data is loaded by AJAX, it is loaded asynchronously without page reload / refresh.
Modern websites uses JSON format instead of XML for data transfer.
In this lecture let's understand What is AJAX and how to make an AJAX call from our JavaScript code using XMLHttpRequest object.
HTTP Status codes: www.restapitut...
Very helpful video, Thanks for this video sir, now I completely understand Ajax and XMLHttpRequest Object
beautiful explanation sir, reach++++++++++++++++++
Thank you sir 🔥🔥🔥🔥
Quality content
Thank you sir for explanation 👍
Well done, thanks.
Please share this channel with others if you like my videos...🤝🤝
let b = new XMLHttpRequest();
b.open("GET","data.txt",true);
b.send();
console.log(b.responseText);
Why the above code not working..?
Have you checked the console?? Is there any error?? Are you getting any CORS related error?
@@procademy no error... simply a blanck page.
same for me too it doesn't update my div(i've ensured ids are correct)
@@thimothy1213 i've cleared my browser history and it worked
Sir onprogress isn't a method...do we need to pass a function to it ?
Onprogress is an event....and to this event, we can assign a function which will get executed when loading data is in progress
If this answer doesn't help....then please be more specific about the question. I will try to answer more precisely.
@@procademy actually you have assigned a object xhr to XMLHT.... Class and called it's methods in the first three cases, but when it comes to on progress you called it as a method like xhr.onprogress, but instead of passing a function into its paranthesis you assied an anonymous function that's where I confused it is a method of xmlhttp.... Class right so we need to use it like xhr.onprogress(fun(){}).
Second;
ok if it's a event then wee need to use it in the params of event listener right ?like variable.addeventlistener('xhr.onprogress',func(){}.. hope you get my doubt if possible could you clear it
That's right. We can also use it like xhr.onprogress(function() {.....}). So, we can pass a callback function to onprogress method. This is one approach
And if you have seen my previous lectures on events, in one of the lectures i have covered that, it is also possible to add an event as a property to a JavaScript object, and to that property, we can assign a function or any JavaScript expression and that function or JavaScript expression will get executed when that event happens. I have used this approach in the example.
Hope this helped. Following is the link for video lecture where i have explained event handler properties.
ruclips.net/video/zprKTWGM4Ek/видео.html
Feel free to ask questions unless your doubt is cleared :)
Could you provide your mail id please
proramming
is there any way to get Outside result of the Function
xmlhttp.onreadystatechange=function(){
if(this.readyState==4 && this.status==200){
var Xs=this.responseText;
}}
i want OutPut Result here, Out Side of the Function.
trying to solve from two month, Please Help