JSCompress fails to compress my js file - why?

Posted by Renso on Geeks with Blogs See other posts from Geeks with Blogs or by Renso
Published on Mon, 22 Mar 2010 06:09:43 GMT Indexed on 2010/03/22 12:21 UTC
Read the original article Hit count: 296

Filed under:

Issue:

You use the online compression utility jscompress.com to compress your js file but it fails with an error. Why this may be happening and how to fix it.

Possible causes:

Apparently not using open and closing curly brackets in an IF statement would cause this. Well turns out this is not the case. Look at the following example and see if you can figure out what the issue is :-)

 

function SetupDeliveredVPRecontactNotes($item, id) {
    var theData;

    $.ajax({
        data: { deliveredVPId: id },
        url: $('#ajaxGetDeliveredVPRecontactNotesUrl').val(),
        type: "GET",
        async: false,
        dataType: "html",
        success: function(data, result) {
            $item.empty();
            var input = '<textarea class="recontactNote" rows="4" name="DeliveredVPRecontactNotes_' + id + '" id="DeliveredVPRecontactNotes_' + id + '" cols="115">' + data + '</textarea>';
            $item.append(input);
            theData = data;
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            $item.empty();
            alert("An error occurred: The operation to retrieve the DeliveredVP's Recontact Notes has failed");
        }
    });                  //ajax

    return theData;
}
 

 

Solution:

The name of the method/function is the same as the message in the ALERT message when the spaces are removed: " DeliveredVP Recontact Notes" becomes " DeliveredVPRecontactNotes" and mathes that of the function. So I changed it to " DeliveredVP's Recontact Notes"

© Geeks with Blogs or respective owner