FoolishOne Posted August 20, 2008 Share Posted August 20, 2008 This is killing me and I am hoping you guys can help. I am using SACK as my 'framework' for this little AJAX side project of mine. Anyone familiar? I have two (2) select boxes. For this test, all I want is to get what the user selected in the select box, with the potential to do a whole bunch with it later (formatting, changing the text, etc.) The first box is full of all 50 states. The function below gets 'state' and 'Texas', and works PERFECTLY. (format-state only has an echo statement in it.) Code: function sack_display(section,value) { alert("in sackdisplay with "+section+" & "+value); ajax.setVar(section, document.getElementById("select-"+section).value); ajax.requestFile = "format-"+section+".php"; // format-state...check ajax.method = "POST"; ajax.element = section+"-content"; //state-content...check ajax.onLoading = whenLoading; ajax.onLoaded = whenLoaded; ajax.onInteractive = whenInteractive; ajax.runAJAX(); } Now, I call it again from a different select box (full of counties) <.... onchange="sack_display('county','Harris County');"> And it doesn't budge. I change the county and the alert doesn't show up, nothing. All the HTML elements are there and visible. If I copy the function and call it display2, and call display 2 from the county select, it works perfectly. I don't want to have a different function for every option box. Everything appreciated. Thanks! Link to comment https://forums.phpfreaks.com/topic/120596-issue-calling-general-ajax-function-multiple-times/ Share on other sites More sharing options...
bluebutterflyofyourmind Posted August 21, 2008 Share Posted August 21, 2008 I've run into a similar issue and would really appreciate some help as well. Link to comment https://forums.phpfreaks.com/topic/120596-issue-calling-general-ajax-function-multiple-times/#findComment-622271 Share on other sites More sharing options...
FoolishOne Posted August 21, 2008 Author Share Posted August 21, 2008 After beating everything out of it I could, I believe that I may have solved my own problem. I can attribute some of my problem to not completely refreshing everything. I am going to try and apply it to a couple other form elements and see if the general function works for more than the 2 of the elements I have it working for currently. Link to comment https://forums.phpfreaks.com/topic/120596-issue-calling-general-ajax-function-multiple-times/#findComment-622313 Share on other sites More sharing options...
bluebutterflyofyourmind Posted August 21, 2008 Share Posted August 21, 2008 how did you solve your problem? Link to comment https://forums.phpfreaks.com/topic/120596-issue-calling-general-ajax-function-multiple-times/#findComment-622377 Share on other sites More sharing options...
FoolishOne Posted August 21, 2008 Author Share Posted August 21, 2008 I double-checked my code on my end, deleted everything remotely involved in the function/call on the server side, re-uploaded everything, and did a forced/hard refresh. My issue involved not refreshing, 2 functions named the same thing , and not properly escaping quotes in the PHP. (Kinda inexperienced at JS, but I noticed that if there is even one error in the JS file, NOTHING will work. My solution was to double click on it in windows explorer. I didn't have anything program associated with it, so it would try and run it, and hence debug it for me.) For people searching later, I believe you can in fact call the function doing the AJAX as many times as you want. It was a 'user error'. In a position like this, the first thing I do/did was put an alert("in here"); or something like that as the first line in the function. If I didn't get a pop-up when I was supposed to, I knew that I couldn't even begin to look at the JS, because it wasn't even getting there. I would check the call in the HTML, and go on from there. Is there a section of code you want to post up? Link to comment https://forums.phpfreaks.com/topic/120596-issue-calling-general-ajax-function-multiple-times/#findComment-622396 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.