5条回答 默认 最新
CZ__ 2018-10-11 06:15关注建议题主看下Ajax的定义和用法,以便理解Ajax的使用。
这里的success,类型是Function,是请求成功后的回调函数。它的参数由服务器返回,并根据 dataType 参数进行处理后的数据;描述状态的字符串。这是一个 Ajax 事件。根据你的情况,重新改了下:
这样可以满足打开页面,就可以初始化input的value。<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <div id="row"></div> </body> <script src="<%=contextPath%>/iis/jquery_mobile/jquery.js"></script> <script type="text/javascript"> function initHtml(){ var soapResp = getRestConfig(); var html='<input type="text" id="'+soapResp.url+'">'; $("#row").html(html); } function getRestConfig(){ var soapResp; $.ajax({ type:"GET", url:"/configs", async:false, success:function(json){ soapResp = $.parseJson(json); } }); return soapResp; } initHtml(); </script> </html>本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
图片说明](https://img-ask.csdn.net/upload/201810/11/1539237152_87641.png)