[英]how to pass value from href link to ajax function
我需要调用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>
那这个解决方案呢?
<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....
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.