PHP 到 jqueryDialog() 交互问题。
我有一个 html 按钮:
<button id="monitor" onclick="startMonitor('<?php echo $result_cameras[$i]["camera_hash"]; ?>', '<?php echo $result_cameras[$i]["camera_name"]; ?>', '<?php echo $camera_quality_flash; ?>');">Monitor</button>
这将加载 flash 内容:
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>
<script type="text/javascript">
var js = jQuery.noConflict();
var startMonitor = function(cameraHash, cameraName, cameraFlashQuality) {
var url = ['flash/app.php?user=<?php echo $id_hash; ?>', 'camera=' + cameraHash, 'name=' + encodeURIComponent(cameraName), 'quality=' + cameraFlashQuality].join('&');
js('<div></div>').load(url, function() {
js(this).dialog();
});
};
我想使用 jquery 对话框打开此内容。传入的所有内容似乎都很完美(根据 firebug 的 GET 响应),但我仍然收到 jquery 错误。
缺少; before statements jquery.js line 612
我做错了什么?我什至不知道如何调试这个。提前致谢。
编辑: Firebug 将 GET 报告为: http://myurl.com/flash/app.php?user=dee8c751cfdd2b5fb8194a3a9bac12044621df3d&camera=8f753c6bb3a8d9852a220abff0ed0d7686563007&name=test22&quality=0
。我期望这些值。
如果我将此 url 粘贴到浏览器中,Flash 应用程序将按预期在浏览器中启动,但显然不会出现 jquery 对话框。我的 jquery 代码一定有问题吗?
I have an html button:
<button id="monitor" onclick="startMonitor('<?php echo $result_cameras[$i]["camera_hash"]; ?>', '<?php echo $result_cameras[$i]["camera_name"]; ?>', '<?php echo $camera_quality_flash; ?>');">Monitor</button>
This would load flash content:
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>
<script type="text/javascript">
var js = jQuery.noConflict();
var startMonitor = function(cameraHash, cameraName, cameraFlashQuality) {
var url = ['flash/app.php?user=<?php echo $id_hash; ?>', 'camera=' + cameraHash, 'name=' + encodeURIComponent(cameraName), 'quality=' + cameraFlashQuality].join('&');
js('<div></div>').load(url, function() {
js(this).dialog();
});
};
I want to use the jquery dialog to open this content. Everything passed in seems to be perfect (according to the GET response from firebug) but I still get a jquery error.
missing ; before statement jquery.js line 612
What am I doing wrong? I'm not even sure how to debug this. Thanks in advance.
EDIT:
Firebug reports the GET as: http://myurl.com/flash/app.php?user=dee8c751cfdd2b5fb8194a3a9bac12044621df3d&camera=8f753c6bb3a8d9852a220abff0ed0d7686563007&name=test22&quality=0
. I expect these values.
If I paste this url into my browser the flash app starts in the browser as expected but not with the jquery dialog obviously. Must be something wrong with my jquery code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(删除了不正确的答案。)
编辑:
最初,我将
jquery.js
误解为您创建的文件,而不是真正的 jquery。测试代码后,我发现您发送的数据可能有问题。您能否发布包含$result_cameras[$i]["camera_hash"]
、$result_cameras[$i]["camera_name"]
、数据的示例$camera_quality_flash
和$id_hash
?另外,结果的url
值是多少?解决方案:
按钮提交表单,页面正在重新加载。该对话框显示,但页面立即重新加载,所以看起来好像从来没有对话框。为了防止这种行为,按钮的
click()
函数必须返回 false (如果没有返回值,则将其视为 true > 结果)。此解决方案的注释:
ready()
事件内。$i
变量),因此数据位于按钮的属性中。) HTML 测试文件:
(Incorrect answer removed.)
Edit:
Initially, I misinterpreted the
jquery.js
as a file you created, rather than the real jquery. After testing out the code, I can see that the data that you are sending may be the problem. Can you post a sample with the data for$result_cameras[$i]["camera_hash"]
,$result_cameras[$i]["camera_name"]
,$camera_quality_flash
, and$id_hash
? Also, what is the value forurl
that results?Solution:
The button submits the form, and the page is reloading. The dialog shows, but then the page is immediately reloaded, so it seems like there never was a dialog. In order to prevent this behavior, the button's
click()
function has to return false (if no value is return, it is treated as a true result).Notes on this solution:
ready()
event.$i
variable in the PHP code), so the data is in the attributes of the button.The HTML test file:
您能确认您显示的返回内容是实际内容吗?
如果是这样,那就不对了,因为它包含 PHP 标签。
但是,如果这是从您的服务器端代码复制的,您能否发布从服务器获得的实际响应,因为这很可能是您的问题所在。
谢谢
Can you confirm that the return content you show is the actual content?
If so, it is not right because it contains PHP tags.
If however this is copied from your server-side code, can you please post the ACTUAL response you get from the server as this is most probably where your problem is.
Thanks