What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

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

    Asked by jonnavarra 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

     

     

     

    undefined in cannot use
  • Profile Image
    JotForm Support

    Answered by Chriistian 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.