TypeError: Cannot use 'in' operator to search for 'custom' in undefined(…)

  • Profile Image
    jonnavarra
    Asked on September 26, 2016 at 10:03 PM

    https://www.jotform.com//?formID=62558838730466

     

    I'm using the form code without integration trying to present and process 3 pages using getJSON with callback option.

    The google script gets triggered, executes and returns the JSON data, however the callback function does not fire, regardless of the type of data I'm requesting back (text, stringtified JSON, raw data).

    In the console is see this and thinking that might be the reason why, but I'm not sure how to fix the error.

    Here is the console message (3x)

    TypeError: Cannot use 'in' operator to search for 'custom' in undefined(…)

    Here is my JS:

     

     $(document).ready(function()

     {

     

        $("#input_2").on("click",function()

     {

    $jQ = jQuery.noConflict();

    var SCRIPT_URL = "https://script.google.com/macros/s/AKfycbzDh_Gi1PMM1uhuX25Q2BOdofxXZQlK_Vx0fbF_at9sVTLACBI/exec";

    alert ("hi "+SCRIPT_URL);

    $jQ.getJSON(SCRIPT_URL+"?callback=?",

    {method:'get_cust_data', acctNum:$jQ("#input_3").val(), custNme:$jQ("#input_4").val()},

    function (data) 

    alert("success");

    alert("json" + JSON.stringify(data)); 

            var items = [];

    $jQ.each( data, function( key, val ) 

    {

        items.push( "<li id='" + key + "'>" + val + "</li>" );

        alert("key: " + key + " value: " + val); 

      });

    })

    .success(function() { alert("second success"); })

    .error(function(err) { alert("AJAX error in request: " + JSON.stringify(err, null, 2)); })

    .complete(function() { alert("complete"); });

     

    });

    });

    Please help.

    Jon

     

     

     

  • Profile Image
    Chriistian
    Answered on September 27, 2016 at 01:54 AM

    The error that you encountered on the console usually suggests that you are using the in operator on a string. To resolve this, you will need to parse the string variable as an object like in this example: $.parseJSON(SCRIPT_URL)

    Here's a thread on stackoverflow that may help: http://stackoverflow.com/questions/4935632/parse-json-in-javascript 

    If the issue persists, may I ask if you have already embedded the form's source code on your webpage? If you have, please give us the URL to that page so we can debug the code further.
    Thank you.