我需要调用ajax函数
...并发送值......
通过href链接
...
但没有通过url
......
我需要打印内容......并且该内容来自数据库......
所以我使用ajax..............
我的 ajax 函数
$(document).ready(function () {
show_customize_image = function () {
alert('test');
$.ajax({
type: "POST",
url: ajax_url_store,
data: {
action: 'store',
views: JSON.stringify(thsirtDesigner.getProduct())
},
success: function (data) {
if (parseInt(data) > 0) {
$("#cart_pd").submit();
}
},
error: function () {
//alert('some error has occured...');
},
start: function () {
//alert('ajax has been started...');
}
});
}
});
我的html
<td class="center">
< a href="javascript:;" onclick="show_customize_image('<?php echo $pageVal['customers_id'];?>');">Delete
< /a>
</td>
最佳答案
这个解决方案怎么样?
<table>
<thead>
<th>Col</th>
<th>Col</th>
</thead>
<tbody>
<tr>
<td>bla</td>
<td class="center"> <a href="javascript:void();" class="tdelete" data="<?php echo $pageVal['customers_id'];?>">Delete</a>
</td>
</tr>
</tbody>
$(document).ready(function () {
$(".tdelete").on("click",function(e){
e.preventDefault();
var varFromPhp = $(this).attr("data"));
//ajax request....
});
});
关于javascript - 如何将href链接的值传递给ajax函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24647329/