两个函数(一个用php)是否可以用“;onclick”;
Are two functions (one with php) possible with "onclick"?
我有下面的脚本,它将同时激发两个函数。一个函数应调用/加载php文件(index.php以查询mysql),另一个函数则应运行javascript。这可能吗?感谢您提前提供的帮助。
$.get("index.php", {id : searchform, name : tweetfinder}, function() {
// Here you can do the other operations
onclick("submit");
$('searchform').submit();
});
</script>
<form id="searchform" name="tweetfinder">
<div class="input-append">
<input class="span3" autofocus="autofocus">
<button class="btn btn-primary">Do Stuff!</button>
</div></form>
这种方法(输入mysql查询作为函数?):
function showstuff(){
<?php
$get = mysql_query("SELECT * FROM `xxx` WHERE `xxx` = '$xxx' ORDER BY `rank` DESC")or die(mysql_error());
while($ass = mysql_fetch_assoc($get)){
$viewer = $ass['playername'];
echo "<a href='"index.php?viewuser=".$viewer."'">".$viewer."</a> , ";
};
如果你愿意使用AJAX(jQuery),那么我建议你。您所做的是,使用AJAX调用获取另一个文件的数据,并在其回调处执行其他操作。
$.get("index.php", {id : 5, name : MyName}, function() {
// Here you can do the other operations
alert('Do more things');
$('formID').submit();
});
有关更多详细信息,请参阅此处
相关文章:
- 是否可以将数组从onClick传递到javascript函数
- 是否可以在Zend表单中显示和隐藏onclick子表单
- 我如何在Capybara中测试页面是否未重新加载(JavaScript onClick拦截有效)
- 是否可以在更改事件之后立即检测到 onclick 事件
- (飞镖)我希望触发两个不同的onclick功能,具体取决于单击时是否选中了单选按钮.我该怎么做
- onblur - 如何分辨点击的内容;或者如何判断 onClick 事件是否正在等待运行
- 是否可以将 onclick 事件附加到文档中的特定坐标
- 是否可以在 HTML 中的“onclick”上运行.exe或.bat文件
- 是否可以使用show/hide javascript来显示具有相同onclick命令的2个元素
- JQuery是否用于onclick/onchange
- 是否可以重新创建一个“;onClick事件“;使用javascript中的自定义事件
- 在onClick函数期间,JavaScript检查字符串是否为空
- 如何使用anchor's onclick事件检查数据库表是否为空
- onclick是否默认为ontouch
- 在onclick中返回的函数是否有html元素
- 在onclick上确定所单击的链接是否意味着打开一个新窗口或选项卡
- onclick属性是否捕获中间点击
- onclick检查该元素是否不是hasClass()
- 是否有可能颠倒onclick事件的顺序?
- onclick是否适用于任何定位?