• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFC 403 Forbidden Error

Guest
Oct 23, 2013 Oct 23, 2013

Copy link to clipboard

Copied

I am trying to invoke a CFC via a URL:

$(function () {

    'use strict';

    // Load countries then initialize plugin:

    $.ajax({

           url: 'https://....countries.cfc?method=getCountries',

       // url: '/autocomplete/content/countries.txt',

        dataType: 'json'

    }).done(function (source) {

        var countriesArray = $.map(source, function (value, key) { return { value: value, data: key }; }),

            countries = $.map(source, function (value) { return value; });

And get the following error:

NetworkError: 403 Forbidden -

Any help in fixing this would be appreciated.

Views

5.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 23, 2013 Oct 23, 2013

Copy link to clipboard

Copied

What happens if you try and access that URL directly in your browser, rather than trying to load it in via AJAX?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 23, 2013 Oct 23, 2013

Copy link to clipboard

Copied

I get the same error

403

Forbidden

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 23, 2013 Oct 23, 2013

Copy link to clipboard

Copied

403 is not a ColdFusion error as such, it is a web server error. Therefore, the resource in question has an access issue e.g. IP block, permission issue, or other security-related issue that is stopping access. The error is also given sometimes when a resource URL cannot be opened. You need to look at that CFC and see where it goes wrong. Debug it line by line and put break points in to see where it gets to before the error is given. Check file paths, any rewrites, and server security settings for the resource. Can you call some code in the CFC before it errors? You have to be Sherlock Holmes sometimes

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 24, 2013 Oct 24, 2013

Copy link to clipboard

Copied

The server admin opened remote access but now I am getting this error:

Error Summary

HTTP Error 404.5 - Not Found

The request filtering module is configured to deny the URL sequence.

When I googled this error I found this:

http://www.iis.net/configreference/system.webserver/security/requestfiltering/denyurlsequences

How can this issue be resolved?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 24, 2013 Oct 24, 2013

Copy link to clipboard

Copied

Is there a simple ajax cold fusion example that does not require remote access?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 24, 2013 Oct 24, 2013

Copy link to clipboard

Copied

The CFC works now when i access it via the url.

Now I need to know how can I change this:

$(function () {

    'use strict';

    // Load countries then initialize plugin:

    $.ajax({

 

    url: 'autocomplete/content/countries.txt',

        dataType: 'json'

    }).done(function (source) {

To this:

$(function () {

    'use strict';

    // Load countries then initialize plugin:

    $.ajax({

            url: 'countries.cfc?method=getCountries',

        dataType: 'json'

    }).done(function (source) {

I tried just added the URL and it doesn't work

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 25, 2013 Oct 25, 2013

Copy link to clipboard

Copied

Please install HTTP trace or use developer tools in the browser to see the HTTP requests. Enable HTTP tracing and then load the page. Are there any errors e.g. 401's or 404's etc. Make sure all URLs in the script are fully qualified (include http, domain and path etc) just to rule out that a file cannot be located.The error with the request filtering module suggests that a URL is either being blocked or is malformed. Post the result of your HTTP trace.

Also, make sure your ajax request is on the same domain - is it?

Also you are calling the ajax script securely - did you try using http:// instead of https:// - is your main page served securely? Some background information would be useful. Please post the code again with made up domain names, if you like.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 25, 2013 Oct 25, 2013

Copy link to clipboard

Copied

I intalled HTTP Trace it gives me no errors

Firebug doesn't either.

I am using a full https path. Yes the page is served securely.

Here is the code: (Domain removed because its our DEV server)

/*jslint  browser: true, white: true, plusplus: true */

/*global $: true */

$(function () {

    'use strict';

    // Load countries then initialize plugin:

    $.ajax({

            url: 'https://...../countries.cfc?method=getCountries',

        dataType: 'json'

    }).done(function (source) {

        var countriesArray = $.map(source, function (value, key) { return { value: value, data: key }; }),

            countries = $.map(source, function (value) { return value; });

        // Setup jQuery ajax mock:

        $.mockjax({

            url: '*',

            responseTime: 2000,

            response: function (settings) {

                var query = settings.data.query,

                    queryLowerCase = query.toLowerCase(),

                    re = new RegExp('\\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi'),

                    suggestions = $.grep(countriesArray, function (country) {

                         // return country.value.toLowerCase().indexOf(queryLowerCase) === 0;

                        return re.test(country.value);

                    }),

                    response = {

                        query: query,

                        suggestions: suggestions

                    };

                this.responseText = JSON.stringify(response);

            }

        });

        // Initialize ajax autocomplete:

        $('#autocomplete-ajax').autocomplete({

            // serviceUrl: '/autosuggest/service/url',

            lookup: countriesArray,

            lookupFilter: function(suggestion, originalQuery, queryLowerCase) {

                var re = new RegExp('\\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi');

                return re.test(suggestion.value);

            },

            onSelect: function(suggestion) {

                $('#selction-ajax').html('Selected Country: ' + suggestion.value + ', ' + suggestion.data);

            },

            onHint: function (hint) {

                $('#autocomplete-ajax-x').val(hint);

            },

            onInvalidateSelection: function() {

                $('#selction-ajax').html('Selected Country: none');

            }

        });

        // Initialize autocomplete with local lookup:

        $('#autocomplete').autocomplete({

            lookup: countriesArray,

            onSelect: function (suggestion) {

                $('#selection').html('Selected Country: ' + suggestion.value + ', ' + suggestion.data);

            }

        });

       

        // Initialize autocomplete with custom appendTo:

        $('#autocomplete-custom-append').autocomplete({

            lookup: countriesArray,

            appendTo: '#suggestions-container'

        });

        // Initialize autocomplete with custom appendTo:

        $('#autocomplete-dynamic').autocomplete({

            lookup: countriesArray

        });

       

    });

});

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 25, 2013 Oct 25, 2013

Copy link to clipboard

Copied

Are the domains of the calling page and the Ajax call the same?

Did you get rid of the "The request filtering module is configured to deny the URL sequence." error, and where and when was that error being shown btw?

Can you also retry with 'use strict'; commented out?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 25, 2013 Oct 25, 2013

Copy link to clipboard

Copied

I am not sure of what you mean by this:

Are the domains of the calling page and the Ajax call the same?

The calling page is like this: https://www.citiprogram.org/index.cfm?pageID=86

The AJAX is in a sub directory of the root. Do they all need to be at the same level?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 25, 2013 Oct 25, 2013

Copy link to clipboard

Copied

Commenting out "use strict" didn't work

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 25, 2013 Oct 25, 2013

Copy link to clipboard

Copied

What I mean is, if the page is served from https://www.citiprogram.org then the Ajax call needs to be targetting the same domain e.g.

$.ajax({ 

url: 'https://www.citiprogram.org/whatever/countries.cfc?method=getCountries',

...

})...

They don't need to be at the same level; I was just trying to work out where your Ajax request was being made to, and you say it is the same domain, so that is another issue ruled out.

So what error do you see now, and at what stage does it occur. Does it occur when the Ajax call is invoked, in which case what HTTP status code do you see for the Ajax request? 200 or 302 etc? Hard to pinpoint an error without seeing the code working.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 25, 2013 Oct 25, 2013

Copy link to clipboard

Copied

Yes they are on the same one.

I don't see an error. It just doesn't work.

It works when I point to a txt doc but not to a CFC.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 25, 2013 Oct 25, 2013

Copy link to clipboard

Copied

is '#selction-ajax' the correct spelling for this DIV? Need to see all the code - can you zip and put it online?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 26, 2013 Oct 26, 2013

Copy link to clipboard

Copied

The code that I am using is here https://github.com/devbridge/jQuery-Autocomplete

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 26, 2013 Oct 26, 2013

Copy link to clipboard

Copied

yes selection is misspelled orignally in the code.

I think I MIGHT know what the problem is.

the countries.txt doc has the data in a certain format:

"AD": "Andorra",

    "AE": "United Arab Emirates",

    "AF": "Afghanistan",

    "AG": "Antigua and Barbuda",

The AJAX code seems to be looking for the data in that format:

   var countriesArray = $.map(source, function (value, key) { return { value: value, data: key }; }),

            countries = $.map(source, function (value) { return value; });

So I need to somehow put my query results in this format.

Thoughts?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 26, 2013 Oct 26, 2013

Copy link to clipboard

Copied

According to the jQuery docs for that autocomplete code, the countries need to look like this (JavaScript array):

var countries = [

   { value: 'Andorra', data: 'AD' },

   ...

   { value: 'Zimbabwe', data: 'ZZ' }

];

perhaps that is what the format needs to be, so that $.map can get the items that it needs? It seems your issue may actually be JavaScript related. Your query to get the countries needs to output them as a JS array perhaps?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 26, 2013 Oct 26, 2013

Copy link to clipboard

Copied

Yes I think the data format is the issue.

Can you give me any suggestions on formatting my query results correctly?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 27, 2013 Oct 27, 2013

Copy link to clipboard

Copied

I downloaded the github jQuery-autocomplete, placed it in a folder and loaded index.htm and it worked straight out of the box for me, so I'm not sure why you are using the CFC at all. It has a countries.txt file with all the country data. Why can't you use this code?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 27, 2013 Oct 27, 2013

Copy link to clipboard

Copied

It works for me too when I use the countries.txt file but I need to use it with data from the database something other than countries

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 28, 2013 Oct 28, 2013

Copy link to clipboard

Copied

Ah, you make no mention of using this script for something other than countries The 'https://....countries.cfc?method=getCountries script needs to produce the same formatted output as countries.txt i.e. like this, and it needs to contain the same two array entries I'd guess:

{

    "AD": "Andorra",

   ...

    "??": "Last entry"

}

Can you ensure that countries.cfc returns this format.

What information do you need to display other than country data? Please be more detailed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 28, 2013 Oct 28, 2013

Copy link to clipboard

Copied

I do need to display th countries but I also need to do this again for a different data set.

That is why I was trying to get the cfc for the countries to work first so I can repeat it on the other data.

The other data is a list of organizations that needs to be pulled from the database. The data changes so a txt doc wouldn't work

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 28, 2013 Oct 28, 2013

Copy link to clipboard

Copied

I understand the need for dynamic data but you've gone well outside the remit of a ColdFusion issue here...

Your countries.cfc?method=getCountries needs to output something. Does it output its data in the same format as in countries.txt? Please do that first; that is very easy to do. Ensure the data that comes out in the page looks like a JavaScript object, like in countries.txt. You need to post some code for countries.cfc

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 28, 2013 Oct 28, 2013

Copy link to clipboard

Copied

No it doesn't. I will need help with the formatting.

Here is the code for the cfc.

<cffunction access="remote" name="getCountries" output="yes" returntype="array">

<cfargument name="search" type="any" required="false" default="">

<!--- Define variables --->

<cfset var data="">

<cfset var result=ArrayNew(1)>

<!--- Do search --->

<cfquery datasource="#request.dsn#" name="data">

SELECT     intCountryId, strCountry

FROM tblCountries

ORDER BY strCountry

</cfquery>

<!--- Build result array --->

<cfloop query="data">

<cfset ArrayAppend(result, strCountry)>

</cfloop>

<!--- And return it --->

<cfreturn result>

    </cffunction>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation