前台代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script src="jquery-3.2-vsdoc2.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" >
        jQuery(function () {
            jQuery.ajax({
                type: "Post",
                url: "/WebService1.asmx/HelloWorld",
                data:"{name:'likong'}",
                dataType: "json",
                contentType:"application/json;charset=utf-8",
                success: function (result) {
                    window.alert(result.d);
                },
                error:function(err){
                    window.alert(err.status);
                    
                }

            })

        })
    </script>
</head>
</html>
View Code

相关文章: