嗨我是一个新的网络编程,我遇到了$ .post函数的问题。jQuery发布功能不起作用!不知道为什么
现在我有一些图片在我的索引页,当我点击他们,我想:
1)去叫viewAlbum
2)获取单击图像源的第二页并将其存储在位于viewAlbum.php页面的$_SESSION['album']
中。
的index.php:
<a href = \"viewAlbum.php\"><img src = " . $url . " alt = " . $caption . " title = " . $caption . "/></a>
(caption is a string)
script.js:
$('img').click(function(){
if(window.location == index){
console.log("1");
var src = $(this).attr("src");
var data = {"Album": src};
}
}
viewAlbum.php:
<?php
if(isset($_POST['Album'])){
print("worked>");
$_SESSION['album'] = $_POST['Album'];
}
else{
print("did not work");
}
?>
这是打印“没有工作”,我不知道如何解决它。请帮忙!
嘛API文档,正是.post的是你提到$标题? – kuncajs 2013-03-20 18:51:46
你有没有在你的代码中使用.post的$对不起 – 2013-03-20 18:53:18
我没有注意到,我离开它在复制的过程中.. 代码: $(“IMG”)点击(函数(){。 if(window.location == index){ console.log(“1”); var src = $(this).attr(“src”); var data = {“Album”:src}; $ .post(“viewAlbum.php”,{“album”:src}); } } – 2013-03-21 07:16:33