如何使用javascript调用PHP函数进行星级引导
为了让这个脚本运行,我绞尽脑汁了几天。也许我的问题很容易解决,但请帮助我。用户可以使用bootstrap en star rating插件对艺术家的歌曲进行评级 请求使用的Javascript:如何使用javascript调用PHP函数进行星级引导,javascript,php,jquery,twitter-bootstrap,Javascript,Php,Jquery,Twitter Bootstrap,为了让这个脚本运行,我绞尽脑汁了几天。也许我的问题很容易解决,但请帮助我。用户可以使用bootstrap en star rating插件对艺术家的歌曲进行评级 请求使用的Javascript: <script type="text/javascript"> jQuery(document).ready(function() { $('#input-id').on('rating.change', function(event, value
<script type="text/javascript">
jQuery(document).ready(function() {
$('#input-id').on('rating.change', function(event, value, caption) {
console.log(value);
console.log(caption);
});
();});
</script>
我的问题:
如何将Javascript与PHP函数结合起来
谢谢。使用ajax调用:
$.ajax({ url: '/myScript.php',
data: {
song_id: 123,
rate: 5
},
type: 'post',
success: function(output) {
alert(output);
}
});
嗨,Daniel,您请求了一个ajax调用,但我不明白php函数SveSongRating在类文件oArtist中的什么位置?Song_id和rate编号应该来自post?我使用submit按钮做了一个变通,并通过获取if$_post['rate']调用该函数。现在还可以。
$rate = $oArtists->SaveSongRating($_POST["song_id"],$_POST["rate"],$userid);
$.ajax({ url: '/myScript.php',
data: {
song_id: 123,
rate: 5
},
type: 'post',
success: function(output) {
alert(output);
}
});