有 AJAX 参考吗? ajaxSubmit() 的作用是什么?它内置于 jQuery 中吗?
这个问题几乎说明了一切。我正在尝试创建一个提交表单,用户可以在其中将信息添加到他们的个人资料中,更新 MySQL 数据库,而无需刷新页面。例如,我希望用户能够添加“爱好”,这就是我现在正在做的事情。
好吧,我正在浏览 StackOverflow 教程,此处,并且我正在尝试查找每个功能。不幸的是,Google 没有提供任何类型的完整 AJAX 参考资料,这让我相信根本就没有。我认为 AJAX 只是发生的事情的名称,它内置于像 jQuery 这样的库中?那么,我如何确定 ajaxSubmit()
和其他 ajax 附加函数的作用呢?
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. Unfortunately, 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您说得对,AJAX 不是一个特定的事物,而是一个松散地描述正在发生的事情的术语。通常使用的是
XMLHttpRequest
对象(由浏览器提供),它允许您向服务器发送请求并获取它们的响应。请注意,在不同的浏览器中执行 AJAX 有不同的方法。这就是为什么最好使用一个库(例如 jQuery)来处理所有这些讨厌的东西,并为您提供干净的界面。
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.
Ajax 的意思是“发出 HTTP 请求并使用 JavaScript 处理响应而不离开页面”。
有很多库提供了帮助函数,使 Ajax 操作变得更加容易。
ajaxSubmit
在您正在查看的答案中定义。如果您无法理解该答案正文中的函数调用的作用,那么值得指出的是,它大量使用了 jQuery,其中 自己的文档。Ajax means "Making an HTTP request and processing the response using JavaScript without leaving the page".
There are plenty of libraries which provide helper functions to make doing Ajax easier.
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()
是一个匿名 函数,当onSubmit 事件被触发。在本例中,当用户单击示例中的提交按钮时。实际上执行 AJAX 请求的 jQuery 函数是 $.ajax()
我建议在继续学习更复杂的概念之前,您需要先学习一些 HTML 和 JavaScript 教程来掌握基本知识。当您已经了解基本概念时,像 jQuery 这样的库非常有用,但它们并不是灵丹妙药。
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.
在该教程中,
ajaxSubmit
正是他命名其函数的方式。您可以在以下行中看到这一点:Ajax 调用的真正魔力发生在
$.ajax()
行中。请参阅 此处 的 jQuery ajax 文档。
In that tutorial
ajaxSubmit
is just the way he has named his function. You can see that in the line:The real magic of the Ajax call is happening in the
$.ajax()
line.See jQuery ajax docs here.