0

同時に2つの関数を起動する次のスクリプトがあります。1 つの関数は php ファイル (mysql を照会するための index.php) を呼び出してロードし、もう 1 つの関数は 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> , ";
};
4

1 に答える 1

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();
});

詳しくはこちら

于 2013-02-14T12:16:33.153 に答える