Search code examples
ajaxproduction-environmentcoldfusion-11

Coldfusion 11 Ajax calls not working on production server


We have 2 identical servers running windows, sql server and coldfusion 11 standard

We have migrated a website to one of the servers but when we copy the site to the second server no AJAX calls work! Everything else works ok just the ajax calls. The only difference between the 2 coldfusion installations is that one is a develpoment server and the other has been configured as a production server.

Why are ajax call not working on the production server?

EXAMPLE - As mentioned the 2 servers have the exact same website files and the exact same database. The development site works but no ajax calls work on the production server.

<script type="text/javascript">
            $(function(){               
                var Location = $("#Location"),
                Other = $("#Other"),
                ContactNo = $("#ContactNo"),
                allFields = $( [] ).add( Location ).add( Other ).add( ContactNo );

            var txtLocation = $('#Location').val();
            var txtOther = $('#Other').val();            
            if(txtLocation == 'Other' || txtLocation == 'Client site'){   
              $('#Other').show();  
            }   
            else{   
              $('#Other').hide();   
            }  

            $('#Location').change( function() {
                var selected = $(this).val();   
                if(selected == 'Other' || selected == 'Client site'){   
                  $('#Other').show();   
                }   
                else{   
                  $('#Other').hide();   
                }  
            }); 

            $('#dialog-MyStatus').dialog({  
                 autoOpen: false,  
                 width: 400,  
                 modal: true,  
                 resizable: false,  
                 buttons: {
                    "Update my status": function() {
                        var bValid = true;
                        allFields.removeClass( "ui-state-error" );       
                        bValid = bValid && checkLength( Location, "ContactNo", 2, 50 );
                        if ($('#Location').val() == 'Other'  || $('#Location').val() == 'Client site'){
                            bValid = bValid && checkLength( Other, "Other", 3, 50 );
                        }

                        if ( bValid ) {
                            //organize the data properly
                            var data = 'method=SetStatus&Location=' + Location.val() + '&Other=' + Other.val() + '&ContactNo=' + 
                            ContactNo.val();                    
                            //start the ajax
                            $.ajax({
                                url: "/templates/cfc/mystatus.cfc", 
                                type: "POST",
                                data: data, 
                                cache: false,
                                success: function (html) {          
                                    //hide the form
                                    $('#MyStatus').fadeOut('slow');
                                    var txtLocation = $('#Location option:selected').text();
                                    var txtOther = $('#Other').val();
                                    var txtContactNo = $('#ContactNo').val();                                       
                                    $('#MyLocation').text(txtLocation);
                                    if (txtLocation != 'Other' && txtLocation != 'Client site'){
                                        $('#MyLocationOther').text('');
                                        $('#MyRemLocation').text(txtLocation);
                                    }
                                    else {
                                        $('#MyLocationOther').text(txtOther);
                                        $('#MyRemLocation').text(txtOther);
                                    }
                                    $('#MyRemContactNo').text(txtContactNo);                                            
                                    $('#MyContactNo').text(txtContactNo);                                           
                                    $('#StatusMessage').text('');   
                                    location.reload();                                      
                                    $('#dialog-MyStatus').dialog("close");  
                                }   
                            });
                        }
                        //cancel the submit button default behaviours
                        return false;
                    }//,
                    //Cancel: function() {
                    //  $(this).dialog("close");
                    //}
                },
                close: function() {
                    allFields.val("").removeClass( "ui-state-error" );
                }                    
             });                 
        });
        function MyStatusSet (){
            $('#MyStatus').fadeIn('slow');
            var txtCurrentLocation = $('#MyLocation').text();
            var txtCurrentLocationOther = $('#MyLocationOther').text();
            var txtCurrentContactNo = $('#MyContactNo').text();
            $("#Location option[value='"+txtCurrentLocation+"']").attr('selected', 'selected');
            $('#Other').val(txtCurrentLocationOther);
            $('#ContactNo').val(txtCurrentContactNo);
            $('#dialog-MyStatus').dialog('open');   
            return false; 
         };
        </script>

Solution

  • Log into the CF Administrator and go to Debugging & Logging > Debug Output Settings and make sure you have enabled the Enable AJAX Debug Log Window option.