我需要致电ajax function
...并发送价值......
按href link
...
但没有经过url
.....
我需要打印内容....而且这些内容来自数据库......
所以我使用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...');
}
});
}
});
<td class="center">
< a href="javascript:;" onclick="show_customize_image('<?php echo $pageVal['customers_id'];?>');">Delete
< /a>
</td>
答案 0 :(得分:2)
这个解决方案怎么样?
<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....
});
});