Discussions

 View Only
  • 1.  URL Encoding Javascript

    Posted 06-29-2020 15:43

    Hello,

    I am trying to Encode a Text Field within a javascript function. 
    The way I have it, it breaks the URL after any special character so its messing up my query.
    If anyone has any experience with this please feel free to comment and assist. 


    Thank You. 

    var span_val = $("span#FIELD_TO_ENCODE").html();
    var url = "";         
           url += "https://rxnb.quickbase.com/db/bqk9ep9fj";             
           url += "?act=API_AddRecord";             
           url += "&apptoken="+qbAppToken;             
           url += "&_fid_7=URLEncode("+span_val;                       
           url += "&_fid_6="+ order_ID;  



    ------------------------------
    Adis Kljajic
    ------------------------------


  • 2.  RE: URL Encoding Javascript

    Posted 06-30-2020 06:52
    One issue that jumps out is in the line you have in bold.  You are missing the closing quotation mark and parenthesis.

    ------------------------------
    Paul Peterson
    ------------------------------



  • 3.  RE: URL Encoding Javascript

    Posted 06-30-2020 10:33
    Adis,
    The syntax error is an issue, but I believe you're looking for encodeURI if this is javascript.  It's documented here:
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI

    ------------------------------
    Neil Schneider
    ------------------------------