Skip to content

Instantly share code, notes, and snippets.

@mm580486
Created October 2, 2019 08:33
Show Gist options
  • Save mm580486/42021f148180fb38abf79107a4ca4a31 to your computer and use it in GitHub Desktop.
Save mm580486/42021f148180fb38abf79107a4ca4a31 to your computer and use it in GitHub Desktop.
$('input[type=radio][name=paymentMethod]').change(function() {
var radio = $(this);
var weight = $('.weight').text();
var price = $('.client-shop-all-price').text();
var request = $.ajax({
url: "https://newkhat.khatoghalam.com/api/shop/v1/add-to-cart",
type: "POST",
cache: false,
data: {
weight: weight,
price: price,
ptoken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJraGF0b2doYWxhbSIsImV4cCI6MTU2OTQ4NTEwMCwiaWF0IjoxNTY5Mzk4NzAwLCJpc3MiOiJraGF0b2doYWxhbSIsImp0aSI6IjNhNjE4YmMyLWRiNDEtNDlmMi05YTkxLTIwNWM4YTYzMGI3YyIsIm5hbWUiOiJzaGFocnlhciIsIm5iZiI6MTU2OTM5ODY5OSwic29tZSI6ImNsYWltIiwic3ViIjoiNGM5MmU2YzEtMmQyMi00Y2I0LWEzMzUtMWUzZTQ4NmVjNjI5IiwidHlwIjoiYWNjZXNzIn0.-bo8ZBUzF8SmqMQujyyY-HYPP3Ly0ZKzprGhqv8Z3xg'
},
dataType: "json"
});
request.done(function(data) {
var json = data;
$('.client-shop-selected-shipping-cost').text(data[postType]);
$('.client-shop-all-paied_price').text(json.namana);
});
request.fail(function(jqXHR, textStatus) {
alert('خطایی در ارتباط با سرور رخ داده است' + textStatus);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment