分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

jquery get-post请求

发布时间:2023-09-06 01:16责任编辑:白小东关键词:暂无标签

API

var reqUrl = "http://192.168.31.162:8081/obtain/onlineState?name=aa01&password=010203";/** * 页面 * ???http://192.168.31.162:8081/http/jquery/Jq01-HttpRequest.html * jquery http get * ?http://www.cnblogs.com/summers/p/3225375.html */function testJqueryHttpGet() { ???debugger; ???$.get(reqUrl, function (data, status) { ???????console.log(data); ???????console.log(status); ???});}/** * jquery http get json */function testJqueryHttpGetJson() { ???debugger; ???$.getJSON(reqUrl, {"height": "1920"}, function (data, status) { ???????console.log(data); ???????console.log(status); ???});}var postUrl = "http://192.168.31.162:8081/update/remoteClientInfo";/** * jquery http post json */function testJqueryHttpPost() { ???debugger; ???var jsonObj = { ???????name: "AAA", ???????pwd: "aaa" ???}; ???$.post(postUrl, JSON.stringify(jsonObj), function (data, status) { ???????console.log(data); ???????console.log(status); ???}, "json", "application/json");}/** * Ref: * ?http://www.jb51.net/article/62703.htm */function testJqueryHttpAjax() { ???debugger; ???$.ajax({ ???????type: "post", ???????dataType: "json", ???????contentType: "application/json", ???????timeout: 3000, ???????url: postUrl, ???????data: ‘{"name":"aa01","password":"010203"}‘, ???????success: function (response) { ???????????console.log(response); ???????}, ???????error: function (request, errorType, errorMessage) { ???????????console.log("[" + errorType + "] " + errorMessage); ???????}, ???????beforeSend: function () { ???????????// do something like .addClass(‘is-fetching‘) ???????}, ???????complete: function () { ???????????// do something like removeClass(‘is-fetching‘) ???????} ???});}

参考:

     jQuery 参考手册 - Ajax

     jQuery - AJAX get() 和 post() 方法 w3c

     jQuery中ajax的4种常用请求方式

     jQuery调用ajax请求的常见方法汇总

jquery get-post请求

原文地址:http://www.cnblogs.com/zhen-android/p/7643394.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved