显示 jquery 对话框
Xml
<?xml version="1.0" encoding="utf-8"?>
<Questions>
<Question>
<Id>1</Id>
<Text>aaaa</Text>
</Question>
<Question>
<Id>2</Id>
<Text>bbb</Text>
</Question>
</Questions>
HTML
<table dir="rtl" width="400px">
<tr>
<td>
<span id="signuptitle">ques* : </span>
</td>
<td>
<select id="sctQuestion" name="D2">
<option></option>
</select>
</td>
</tr>
Code1
function PopupUserRegist() {
$.ajax({
type: "GET",
url: "../Administrator/Questions.xml",
success: parseXmlQuestion
});
function parseXmlQuestion(xml)
{
$(xml).find("Question").each(function()
{
var value=$(this).find('Text').text();
$("#sctQuestion").
append($("<option></option>").
attr("value",value).
text(value));
});
}
$("#div_userregist").dialog("open");
}
$(function () {
$("#dialog:ui-dialog").dialog("destroy");
$("#div_userregist").dialog({ autoOpen: false,
buttons: {
"ok!": function () {
}
});
});
此代码获取 XML 成功。
=================================================== ==========================
Code2
function PopupUserRegist() {
$.ajax({
type: "GET",
url: "../Administrator/Questions.xml",
success: parseXmlQuestion
});
function parseXmlQuestion(xml)
{
$(xml).find("Question").each(function()
{
var value=$(this).find('Text').text();
$("#sctQuestion").
append($("<option></option>").
attr("value",value).
text(value));
});
}
$(function () {
$("#dialog:ui-dialog").dialog("destroy");
$("#div_userregist").dialog({ autoOpen: true,
buttons: {
"ok!": function () {
}
});
});
}
此代码未成功获取 XML。
=================================================== ===============
===================================== ==============================
在 Code1: autoOpen: false 和在 code2: autoOpen: true
在 code1 中获得 xml 成功,但在code2:未获取 xml。
Xml
<?xml version="1.0" encoding="utf-8"?>
<Questions>
<Question>
<Id>1</Id>
<Text>aaaa</Text>
</Question>
<Question>
<Id>2</Id>
<Text>bbb</Text>
</Question>
</Questions>
HTML
<table dir="rtl" width="400px">
<tr>
<td>
<span id="signuptitle">ques* : </span>
</td>
<td>
<select id="sctQuestion" name="D2">
<option></option>
</select>
</td>
</tr>
Code1
function PopupUserRegist() {
$.ajax({
type: "GET",
url: "../Administrator/Questions.xml",
success: parseXmlQuestion
});
function parseXmlQuestion(xml)
{
$(xml).find("Question").each(function()
{
var value=$(this).find('Text').text();
$("#sctQuestion").
append($("<option></option>").
attr("value",value).
text(value));
});
}
$("#div_userregist").dialog("open");
}
$(function () {
$("#dialog:ui-dialog").dialog("destroy");
$("#div_userregist").dialog({ autoOpen: false,
buttons: {
"ok!": function () {
}
});
});
This code Get XML successes.
==========================================================================
Code2
function PopupUserRegist() {
$.ajax({
type: "GET",
url: "../Administrator/Questions.xml",
success: parseXmlQuestion
});
function parseXmlQuestion(xml)
{
$(xml).find("Question").each(function()
{
var value=$(this).find('Text').text();
$("#sctQuestion").
append($("<option></option>").
attr("value",value).
text(value));
});
}
$(function () {
$("#dialog:ui-dialog").dialog("destroy");
$("#div_userregist").dialog({ autoOpen: true,
buttons: {
"ok!": function () {
}
});
});
}
This code does not Get XML successes.
=================================================================
=================================================================
in Code1: autoOpen: false and in code2: autoOpen: true
in code1 get xml success but in code2: does not get xml.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当对话框自动打开时,可能是在 XML 完全加载和解析之前。我将在
parseXmlQuestion()
末尾调用该对话框,以便脚本的所有部分的计时都是正确的。如果您在用户等待时需要加载指示器,请使用如下内容:
When the dialog is autoOpened, it may be before the XML has been fully loaded and parsed. I would call the dialog at the end of
parseXmlQuestion()
so that the timing is correct for all parts of your script.If you need a loading indicator while the user waits, use something like this: