2013-02-14 57 views
0

我有下面的脚本,它应该同时激发两个函数。一个函数应该调用/加载一个php文件(index.php来查询一个mysql),另一个应该运行一个javascript。这甚至有可能吗?感谢您的帮助提前。两个函数(一个用php)可能与“onclick”?

$.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> , "; 
}; 
+1

与JavaScript不,你不能调用PHP函数,你需要学习客户端和服务器端脚本 – 2013-02-14 12:10:30

+0

一个新的URL *之间的差异*提交表单相互矛盾。请解释你试图用什么来实现。 – bfavaretto 2013-02-14 12:11:47

+3

这取决于你的定义同时... – 2013-02-14 12:12:16

回答

0

如果你愿意你的AJAX(jQuery的),那么我想建议。你做什么,使用AJAX调用获取其他文件的数据,并在其回调中执行其他操作。

$.get("index.php", {id : 5, name : MyName}, function() { 
    // Here you can do the other operations 
    alert('Do more things'); 
    $('formID').submit(); 
}); 

欲了解更多详情,请参阅here

+0

非常感谢。我会立即尝试。 – NuriK 2013-02-14 12:20:29

+0

经过2个小时的尝试,我无法正确理解。我编辑的代码在当前的问题...仍然很长的路要走,我... – NuriK 2013-02-14 14:52:40

相关问题