jQuery AJAX に渡す URL があります。
<a href="/wishlist.php?sku=C5&action=move&qty=1" class="buttoncart black">Move To Wishlist</a>;
AJAXに到達したら、href属性を次のように変更したい
<a href="/ajax_page.php?sku=C5&action=move&qty=1">Move blaf</a>
私はまだ初心者です。きっと簡単な方法があるはずです。これが私のスクリプトです。
var wishorder = {
init: function(config){
this.config = config;
this.bindEvents();
},
bindEvents: function(){
this.config.itemSelection.on('click',this.addWish);
},
addWish: function(e){
console.log('working');
console.log($(this).attr('href').pathname);
var self = wishorder;
$.ajax({
//this is where im using the href and would like to change it
//but i cant seem to access to get variables
url: $(this).attr('href'),
//url: '/ajax/ajax_move.php',
type: 'GET',
data: {
sku: $(this).data('sku'),
action: $(this).data('action'),
qty: $(this).data('qty')
},
success: function(results){
console.log(results);
$('#cartcont').html(results);
}
});
e.preventDefault();
}
};
wishorder.init({
itemSelection: $('#carttable tr a'),
form: $('#cartfrm')
});