开发者

Is there an AJAX reference? What does ajaxSubmit() do? Is it built into jQuery?

开发者 https://www.devze.com 2023-04-13 03:24 出处:网络
The question pretty much says it all.I\'m trying to create a submission form where users can add information to their profile, updating the MySQL database, without page refresh.For example, I want use

The question pretty much says it all. I'm trying to create a submission form where users can add information to their profile, updating the MySQL database, without page refresh. For example, I want users to be able to add 'hobbies', which is what I'm working on right now.

Well, I'm going through a StackOverflow tutorial, here, and I'm trying to look up each of the functions. Unfortuna开发者_运维问答tely, google's not turning up any kind of complete AJAX reference, leading me to believe there isn't one out there. I think AJAX is just the name of something that happens, and it's built into libraries like jQuery? So, how do I figure out what ajaxSubmit() and other ajax-appended functions do?


You're right about AJAX not being a specific thing, but a term that loosely describes what is happening. What is normally used is a XMLHttpRequest object (provided by browsers), which allows you to send requests to the server and get their response.

Beware, there are different ways of doing AJAX in different browsers. This is why it's so much better to use a library (such as jQuery) that handles all that nasty stuff, and provides you with a clean interface.


I think AJAX is just the name of something that happens

Ajax means "Making an HTTP request and processing the response using JavaScript without leaving the page".

and it's built into libraries like jQuery?

There are plenty of libraries which provide helper functions to make doing Ajax easier.

So, how do I figure out what ajaxSubmit() and other ajax-appended functions do?

ajaxSubmit is defined in the answer you are looking at. If you have trouble understanding what the function calls in the body of that answer do, then it is worth pointing out that it makes heavy use of jQuery which has its own documentation.


ajaxSubmit() is an anonymous function that is called when the onSubmit event is triggered. In this case, when the user clicks on the submit button in the example.

jQuery function that is actually doing the AJAX request is $.ajax()

I would suggest that you go through a couple of HTML and JavaScript tutorials to get a grasp on basic stuff before moving on to more complicated concepts. Libraries like jQuery are useful when you already know the underlying concepts, but they are not a silver bullet.


In that tutorial ajaxSubmit is just the way he has named his function. You can see that in the line:

var ajaxSubmit = function(...

The real magic of the Ajax call is happening in the $.ajax() line.

See jQuery ajax docs here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号