Search code examples
htmlajaxasp-classic

Add parameter to AJAX in Classic ASP


In addition to "PaymentID" need to add another parameter to exiting AJAX call for variable "CurrUserID", see existing code below:

<script>
     function cback_<%=objRS("PaymentID")%>(text) 
              document.getElementById('tr_<%=objRS("PaymentID")%>').innerHTML = text;
      }
      doAjax('/receipt_ajax.asp','PaymentID=<%=objRS("PaymentID")%>','cback_<%=objRS("PaymentID")%>','get','0')
</script>

Need help on Syntax, I have tried adding comma plus Parmenter and concatenating using & or +


Solution

  • The URL syntax is page.asp?key1=val1&key2=val2, so your code most likely needs to be

    doAjax('/receipt_ajax.asp',
    'PaymentID=<%=objRS("PaymentID")%>&CurrUserID=<%=objRS("CurrUserID")%>' 
    

    where <%= %> injects the server side value to output the value of objRS("CurrUserID"). If all is correct, the page code will get

     doAjax('/receipt_ajax.asp','PaymentID=...&CurrUserID=...'
    

    More on asp syntax here.