如何在jquery对话框中将来自服务器的消息用作文本
我是jquery的初学者,对于如何在jquery对话框中将来自服务器的消息用作文本,我有一个问题 我知道jquery对话框的基本用法如下:如何在jquery对话框中将来自服务器的消息用作文本,jquery,Jquery,我是jquery的初学者,对于如何在jquery对话框中将来自服务器的消息用作文本,我有一个问题 我知道jquery对话框的基本用法如下: $( function() { $( "#dialog" ).dialog(); } ); <div id="dialog" title="Basic dialog"> <p>This is the default dialog which is useful for displaying information.
$( function() {
$( "#dialog" ).dialog();
} );
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
如果出现错误,我希望使用如图所示的api。
可能吗?怎么做
谢谢是的,这是可能的。给p标签一个id
<div id="dialog" title="Basic dialog">
<p id="message">This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
我知道您希望使用对话框显示来自Ajax请求的错误消息 请参阅下面代码中的注释。。。看一看 $function{ //对话框被实例化 $dialog.dialog; //您看到默认对话框打开的超时时间为2秒。。。 //然后,尝试一个Ajax请求。 setTimeoutfunction{ //关闭对话框 $dialog.dialogclose; //肯定会失败的Ajax请求 $.ajax{ 网址:https://some-bad-domain.com/some-bad-URL.php, 方法:获取, 数据类型:json, 成功:功能{ //这里是成功代码 }, 错误:函数XHR、状态、错误{ //这里有错误代码 //设置对话框的文本 $dialog p.text JSON.stringifyxhr; //打开对话框 $dialog.dialogopen; } }; },2000; }; 这是用于显示信息的默认对话框。可以使用“x”图标移动、调整和关闭对话框窗口 什么是show\u jquery\u对话框?
<div id="dialog" title="Basic dialog">
<p id="message">This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
show_jquery_dialog(message){
$("#message").text(message);
//add code to show the dialog
}