标签:tty put lang 4.0 ext get script javascrip odi
用$.isEmptyObject(对象)来判断 空返回true 否则为false
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <!-- 引入jquery.js --> <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.3.1.min.js"></script> <script type="text/javascript"> $(function () { $("#sb").click(function () { var str = document.getElementById("su"); var st=str.value; $.ajax({ url:"/Home/mail/find", data:{number:st}, dataType:"json", success:function (mobile) { console.log($.isEmptyObject(mobile.mobileNumber)); console.log(mobile); if(!$.isEmptyObject(mobile.mobileNumber)){//不为空 console.log(mobile); var msg = mobile.mobileNumber+"=>"+mobile.mobileArea+"=>"+mobile.mobileType; $("#result").html(msg); }else{ $("#result").html("不存在"); } } }) }) }); </script> </head> <body> <form > <input id="su" type="text" name="number"> <input id="sb" type="button" value="查询归属地"> </form> <div id="result"></div> </body> </html>
标签:tty put lang 4.0 ext get script javascrip odi
原文地址:https://www.cnblogs.com/charlypage/p/9021639.html