Hello, in this jQuery method, I'm going to show you how to use the get Ajax method. So I've got a back end server file right here called favorites dot php. So it is a PHP file that has to be PHP, it could be, you know, ASP, for example can be any back end language, create equal create any back end, follow me using the back end line, that's your choice. And you just use the one you want to on this using PHP as a is my favorite. And from there I've echoed eight, which is, you know, they're the, you know, it's the way that you send data back. When you use an Ajax using PHP, that's a piece of the best.
So what we're looking at is how to get that data. What language did in the back end if the data being sent correctly, it will be received correctly. So what we are going to do to actually get it you do dollar dot get and then your brackets the first parameter is the low keishon of this back end file for me from the same location, everything else famous dot php. And comma, now we're going to have a function callback. And it's going to take two parameters, the data and the status data. Well, you know, tell us if anything's gone wrong, and we'll actually make something go wrong.
Once it's gone successful, hopefully successful. From here, we'll be confident log. And we put data, then we do console dot log, and you can get all the status. So if we reload it click me, I didn't see this is the best and success. But what happened if I missed a rep and that Father exist on my server as you can see upload folder there. And if I click it, I didn't see it gets an error, we are getting an error from here.
And if the you know any other status as well, we will get that accordingly. So favorite red dot php. I think he's got pieces best. Obviously, this could be as simple complex as you want. So you could return some HTML, for example. So I could say, I could say, old tag, close this tag.
And you could have multiple echo lines up again, What language are you using the back end will vary. And as a result, the code in the back end will vary, but the way you retrieve it will be the same. Now if I reload it, click me, I think he's got you know that. And if I were to, let's say, creating a div. And that's all I really need. And if I said and I'm gonna be dollar from the selected dot html, so I'm going to override the HTML inside the div config data as you can see it It's got the HTML pizzas, the best if I reload, go to body and see this is empty is David, click me.
You got some content, and it is the pizza is the best HTML. So you can add it to your HTML pages, which is fantastic. As you can see, you know, we're not obviously going to keep overriding it now. But the pages when we load them, it's not doing a full reload or refresh. That's fantastic. So maybe to get data from a back end file without having to you know, reload default, not amazing use case of this is not directly returning some data that's already in the file.
If maybe that, you know, file itself is hooked up to a database, and he gets data from the database. So the data you get, let's say, when you click it now could be different to when if you were to click in an hour's time, because a social networking site, for example. So really simple stuff, but really powerful as well. Thanks for watching. If you have any questions, feel free to ping me A message, I will provide a awesome link for more Ajax functions and unusual. I look forward to seeing you in the next video.