[英]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.