zoukankan      html  css  js  c++  java
  • vue和jQuery嵌套实现异步ajax通信

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>vue和jQuery嵌套实现异步ajax通信</title>
        <script src="../js/jquery.min.js"></script>
        <script src="../js/vue.js"></script>
        <script>
            // 可以兼容jQuery和vue的单一入口
            window.onload = function(){
                var app = new Vue({
                    el:"#app",
                    // vue内置属性用来绑定事件
                    methods:{
                        get:function(){
                            // 发送get请求
                            $.ajax({
                                // 指定请求方式
                                type:"GET",
                                // 网址,ajax.php特制的服务器端请求
                                url:"http://192.168.1.238/ajax.php",
                                // 数据格式,jsonp是一种跨域请求的格式
                                dataType:"jsonp",
                                // 回调函数
                                jsonp:"callback",
                                // 通信成功后,打印服务器端返回的数据
                                success:function(msg){
                                    // alert(msg.text);
                                    // 使用jQuery实时渲染页面(改变div盒子)的内容
                                    $("#message").html("下午好,您已成功登录!")
                                }
                            });
                        }
  • 相关阅读:
    Windows——bat中的路径和工具栏运行bat的坑
    KBE——查询
    KBE实践——登录案例
    KBE_运作流程
    KBE_创建项目和基本常识
    python_面向对象
    程序员常见面试之 数据库 知识点小结(三)
    C#编程总结
    人人必知的10个 jQuery 小技巧
    Javascript生成二维码(QR)
  • 原文地址:https://www.cnblogs.com/lutt/p/10427553.html
Copyright © 2011-2022 走看看