jQuery.ajax url: rails
In my code I have this button
<button class="btn btn-success btn-lg" id="check_module">Pay</button>
In my code I have this button
Pay
Expand snippet
when clicked on iframe opens from this javascript code
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="https://service.iamport.kr/js/iamport.payment-1.1.5.js"></script>
<%= javascript_tag do %>
$("#check_module").click(function () {
IMP.init(''); //iamport 대신 자신의 "가맹점 식별코드"를 사용하시면 됩니다
IMP.request_pay({
merchant_uid : "<%= @merchant_uid %>",
name : '결제테스트',
amount : <%= @price %>,
buyer_email : '<%= current_user.email %>',
buyer_name : '<%= current_user.name %>',
buyer_tel : ' no phone ',
buyer_addr : ' course name: no address',
buyer_postcode : ' no postcode ',
m_redirect_url: "https://url"
}, function(rsp) {
if ( rsp.success ) {// Successful payment: Successful payment approval or issuance of a virtual account
// HTTP request using jQuery
jQuhttps://stackoverflow.com/questions/ask#ery.ajax({
url: "<%= payment_complete_path(:item_id => @item) %>", // Merchant server
method: "POST",
headers: { "Content-Type": "application/json" },
data: {
imp_uid: rsp.imp_uid,
merchant_uid: rsp.merchant_uid
}
}).done(function (data) {
// Logic executed on successful response from the merchant server through the payment API
})
} else {
var msg = '결제에 실패하였습니다.';
msg += '에러내용 : ' + rsp.error_msg;
}
});
});
<% end %>
but after submitting the form the transaction goes through successfully but it stays on the page
how can I make it to go to this url or this action
url: "<%= payment_complete_path(:item_id => @item) %>", // Merchant server
in my controller ?
Any help will be greatly appreciated. Thank you!