Home > Web Front-end > JS Tutorial > How to get the contents of the database through jQuery

How to get the contents of the database through jQuery

coldplay.xixi
Release: 2020-11-26 15:46:25
Original
4095 people have browsed it

How to obtain database content through jQuery: You can use [jQuery.ajax()] to achieve it. The code is [jQuery.ajax({type: "post",url: "XX.htm",data: {value : $(this).val()}】.

How to get the contents of the database through jQuery

  • ##This method is applicable to all brands of computers

Methods to obtain database content through jQuery:

JQuery can interact with the database using

jQuery.ajax(), AJAX is a A technology for exchanging data with the server.

The usage is as follows:

jQuery.ajax({
           type: "post",//也可以是get方式
           url: "XX.htm",//访问数据库的路径,也可以是XX.jsp,XX.asp等
           data: {
               value : $(this).val()//要传递的参数,可以是一个json对象,反正都是键值对
           },
           success: function(data, textStatus){
               //成功回调函数
           },
           error: function(){
               //失败返回调用调用
               alert("操作有误!");
           }
})
Copy after login

Parameter description:

1,

url

Description : The address to send the request (default is the current page), the requirement is a String type parameter, for example, under .net, "~wexin(controller)/getweinxinmenu(action)",

2,

type

Description: Request method (post or get), the default is get, the requirement is String type parameters. Other http requests such as (put, delete) are also supported, but they must be supported by the browser

3,

data

Note: The data sent to the server must be a parameter of type Object or string. If it is not a string, it will be automatically converted to a string. Format. The get request will be appended to the url.

Related free learning recommendations:

javascript (video)

The above is the detailed content of How to get the contents of the database through jQuery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template