如何在脚本中执行函数?

时间:2016-03-09 19:10:38

标签: javascript function

我想在javascript代码执行时执行这些函数;



function check_count2($userid,$picid){
	$sql5 = "select count(*) from abctable 
			where persona='$kuladii123' and personb='$resimid'";
	$result5 = mysql_query($sql5);

	$row5 = mysql_fetch_row($result5);
	return $row5[0];

}

function myfunction($userid,$picid){
	$test = check_count2($userid,$picid);

	if ($test == 0){
		$sql6 = "insert into abctable (persona,personb) 
				values ($userid,$picid)";

		$result6 = mysql_query($sql6);
	}
}




Javascript代码;



<script type="text/javascript">
  
$(".photos'.$picid.'").waypoint(function() {       

         myfunction(); // I WANT THIS FUNCTION HERE!

        }
});

</script>
&#13;
&#13;
&#13;

我无法打电话给我,请帮助我。

1 个答案:

答案 0 :(得分:0)

要使用javascript执行php函数,您需要AJAX。您需要创建一个执行该函数的php文件的ajax调用。

mainForm = new MForm();//mainForm will be null because the constructor got aborted or something