AJAX not populating dropdown in ColdFusion
AJAX not populating dropdown in ColdFusion
(OP)
Hello geniuses,
I have inherited a ColdFusion application which uses four lines of AJAX in order to populate a drop-down based upon the
selection made in a previous drop-down. The first drop-down is a list of car "makes", for example: Ford, Chevrolet, etc. The second drop-down is to be populated with "models" based upon the selected "make".
However, the AJAX code appears to be no-longer working as the "models" drop-down is not being populated. We recently had to move the code to a new server, and it seems like, from that point forward, the AJAX is not populating the "models"
drop-down.
Here is the code:
<SCRIPT LANGUAGE="JavaScript" SRC="prototype.js"></script>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
function doIt(){
makename = document.addvehicle.MAKE.value;
var url = 'https://fisnet.wvu.edu/secure/_listmodels.cfm';
var pars = 'make='+makename+'&edit=0';
var myAjax = new Ajax.Updater('models', url, { method: 'get',
parameters: pars });
}
</SCRIPT>
Now, one change which had to be made was to update the URL variable from being only HTTP to HTTPS because this application
is now behind that level of security. Other than that, the code is exactly the same now as it used to be.
One more thing, this code works differently based on the browser used. To explain, while the code is no-longer populating the drop-down, in FireFox it makes the "models" drop-down disappear completely, as though it's trying to update it, but something is failing. In IE 9 the drop-down remains, it just does not get populated. For IE 8 and Chrome there is a
JavaScript error earlier in the application which prevents it from working, so I don't know how this AJAX code works in those browsers.
I do not know AJAX or JavaScript, I have never worked with them before, I am a ColdFusion developer with intermediate skill. I hope to be able to follow along with any suggestions or comments, I will try my best to do so. Please let me know if I can provide you with any additional information.
Thank you very much,
Jim
I have inherited a ColdFusion application which uses four lines of AJAX in order to populate a drop-down based upon the
selection made in a previous drop-down. The first drop-down is a list of car "makes", for example: Ford, Chevrolet, etc. The second drop-down is to be populated with "models" based upon the selected "make".
However, the AJAX code appears to be no-longer working as the "models" drop-down is not being populated. We recently had to move the code to a new server, and it seems like, from that point forward, the AJAX is not populating the "models"
drop-down.
Here is the code:
<SCRIPT LANGUAGE="JavaScript" SRC="prototype.js"></script>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
function doIt(){
makename = document.addvehicle.MAKE.value;
var url = 'https://fisnet.wvu.edu/secure/_listmodels.cfm';
var pars = 'make='+makename+'&edit=0';
var myAjax = new Ajax.Updater('models', url, { method: 'get',
parameters: pars });
}
</SCRIPT>
Now, one change which had to be made was to update the URL variable from being only HTTP to HTTPS because this application
is now behind that level of security. Other than that, the code is exactly the same now as it used to be.
One more thing, this code works differently based on the browser used. To explain, while the code is no-longer populating the drop-down, in FireFox it makes the "models" drop-down disappear completely, as though it's trying to update it, but something is failing. In IE 9 the drop-down remains, it just does not get populated. For IE 8 and Chrome there is a
JavaScript error earlier in the application which prevents it from working, so I don't know how this AJAX code works in those browsers.
I do not know AJAX or JavaScript, I have never worked with them before, I am a ColdFusion developer with intermediate skill. I hope to be able to follow along with any suggestions or comments, I will try my best to do so. Please let me know if I can provide you with any additional information.
Thank you very much,
Jim
RE: AJAX not populating dropdown in ColdFusion
First of all, are you sure that URL is working ?
Feherke.
feherke.github.io
RE: AJAX not populating dropdown in ColdFusion
Thank you for taking the time to ask me a question and for trying to help me, I really appreciate it.
Well, that's a brilliant question to ask! I THOUGHT it was working, and it is working, but the problem is that you have to be logged into the application first in order for that URL to work. See, this application, which is called FISNET, has a login on it. If you hit that URL, it first asks you to login. Once you login, if you hit that URL again, it does work.
But that right there is the rub, you have to login first, AJAX doesn't know that, it can't login for me, thus it's getting stopped and it not returning any data is totally correct.
The problem, then, is occurring because I am working in a development environment which uses a different URL! If I update the URL to use the developement URL, it works without a login because I've already logged in, the drop-down is accessible.
Man, who would have thought? I need a development URL for it to work in development, and a production URL for it to work in production. That's the other thing, FISNET used to be just HTTP, but now it's HTTPS, thus the URL is different, in fact, the HTTP FISNET doesn't work anymore.
Thank you so much for getting me to track that down! Are there points or anything I can assign to you, other than extreme thanks and well-wishes from me?
Please accept my sincere thanks and best wishes to you! Have a great Friday and weekend!
Jim
RE: AJAX not populating dropdown in ColdFusion
Hmm... Does that happen in FireFox ? Are all URLs changed into https ? Because in FireFox 23 was added something Mixed Content Blocking. ( No idea whether applies in your case, just remembered seeing this recently. )
Regarding the development vs production URL. When you change, are all URLs changed ? Because if not, the AJAX response may be rejected due to Same origin policy. In this case you will have to add Access-Control-Allow-Origin HTTP response header to _listmodels.cfm's output, according to Cross-Origin Resource Sharing.
Feherke.
feherke.github.io
RE: AJAX not populating dropdown in ColdFusion
RE: AJAX not populating dropdown in ColdFusion
I have the same problem. I've looked at return results in firebug and the json look ok to me. I get an empty suggest list, the suggest list row count matched the array length but all the rows are empty?
json array:
CODE
CODE
Lyndon
---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
RE: AJAX not populating dropdown in ColdFusion
CODE
If your server side is coldfusion then you may be interested in the server side code I used.
CODE
Lyndon
---People Remember about 10% of what you say ---They never forget how you made them feel. Covey