title: How do you call a function in a redirect field?
body: <p>I think it would be better to show you the code first before I explain:</p>
  <pre><code>$(function() {
      var IMP=window.IMP;
      IMP.init('11111111');
      $('.order-form').on('submit', function(e) {
          var amount = parseFloat($('.order-form input[name=&quot;amount&quot;]').val().replace(',',''));
          var type=$('.order-form input[name=&quot;type&quot;]:checked').val();
          var order_id = AjaxCreateOrder(e);
          if(order_id==false) {
              alert('주문 생성 실패\n다시 시도해주세요.');
              return false;
          }
  
          var merchant_id = AjaxStoreTransaction(e, order_id, amount, type);
  
          if(merchant_id!=='') {
              IMP.request_pay({
                  merchant_uid:merchant_id,
                  name:'Product',
                  buyer_name:$('input[name=&quot;first_name&quot;]').val()+&quot; &quot;+$('input[name=&quot;last_name&quot;]').val(),
                  buyer_email:$('input[name=&quot;email&quot;]').val(),
                  amount:amount,
                  m_redirect_url: 'mywebsite/payments/complete',
              }, function(rsp) {
                  if(rsp.success) {
                      var msg = '결제가 완료되었습니다.';
                      msg += '고유 ID : '+rsp.imp_uid;
                      // 결제 완료후 보여줄 메시지
                      ImpTransaction(e, order_id, rsp.merchant_uid, rsp.imp_uid, rsp.paid_amount);
                  } else {
                      var msg = '결제에 실패하였습니다.';
                      msg += '에러내용 : '+ rsp.error_msg;
                      console.log(msg);
                  }
              });
          }
          return false;
      });
  });
  
  
  function ImpTransaction(e, order_id, merchant_id, imp_id, amount) {
      e.preventDefault();
      var request = $.ajax({
          method:&quot;POST&quot;,
          url:order_validation_url,
          async:false,
          data:{
              order_id:order_id,
              merchant_id:merchant_id,
              imp_id:imp_id,
              amount:amount,
              csrfmiddlewaretoken:csrf_token
          }
      });
      request.done(function(data) {
          if(data.works) {
              $(location).attr('href',location.origin+order_complete_url+'?order_id='+order_id)
          }
      });
      request.fail(function(jqXHR, textStatus) {
          if(jqXHR.status == 404) {
              alert(&quot;페이지가 존재하지 않습니다.&quot;);
          } else if(jqXHR.status==403) {
              alert(&quot;로그인 해주세요.&quot;);
          } else {
              alert(&quot;문제가 발생했습니다.\n다시 시도해주세요.&quot;);
          }
      });
  }
  </code></pre>
  <p>As you can see, I am using an Iamport(IMP) API, but that is not really important. What I want is when I run the <code>m_redirect_url: 'mywebsite/payments/complete'</code>, I want to be able to run the <code>ImpTransaction()</code> simultaneously before reirecting to the url <code>mywebsite/payments/complete</code>. This is because the callback function <code>function(rsp)</code>  does not work when I am using my django website on mobile. <code>m_redirect_url</code> is the url I redirect the user to once the transaction is complete in mobile.</p>
  <p>Thank you, and please leave any comments or questions you have below.</p>