esscher Posted February 24, 2008 Share Posted February 24, 2008 I am a ajax newbie so be kind please! I'm not sure if my title made sense, but I'll try to be clear about my question. Why does the javascript that is in the page that I have requested from xmlHTTPRequest.open not get interpreted/read? When I bring back the page, nothing that is in <script language="javascript"></script> gets printed to the screen. Does that make sense? Esscher Quote Link to comment Share on other sites More sharing options...
mainewoods Posted February 25, 2008 Share Posted February 25, 2008 I assume when you get back the javascript, you innerHTML it into something. The problem is with the innerHTML, it doesn't understand javascript. Because of that, executing javascript that is returned from ajax is not a simple matter. Quote Link to comment Share on other sites More sharing options...
esscher Posted February 26, 2008 Author Share Posted February 26, 2008 Yes, that is what I have found out on other forums as well. Its a bummer, because if it were more of a simple matter, I think that ajax would be many times more powerful. Because of this, I cannot figure out how to keep multiple submit operations on the same page. ie, submit to search a database and populated a form based on that search, and submit that form to be inserted into a database, all on one page (no reloads). It looks like I may have to look to adobes flex 2 to accomplish this. any other ideas? Esscher Quote Link to comment Share on other sites More sharing options...
mainewoods Posted February 26, 2008 Share Posted February 26, 2008 what exactly are you saying you're trying to do? 1) ajax is called with query vars 2) php does db query 3) ajax recieves return values 4) form fields are populated with values 5) you want the form to be submitted back through ajax and stored in some db table? how come step #5 can't be done in step #2? You're getting the info that #5 is supposed to storing, so why not do step #5 in #2? Just pass an extra query var flag in #1 to signify that #2 is to retrieve the data, store the data in a different table/format and then return back through ajax. Quote Link to comment Share on other sites More sharing options...
esscher Posted February 26, 2008 Author Share Posted February 26, 2008 mainewoods, i'm not sure what you mean by "pass an extra query var flag" Here is the url http://66.87.141.7/phytobase/p2/demo_add_plant-post.phP to the application I'm building. I think it may be easier to show you than to explain it. First thing you do is type in the name of a plant (anything will do for now) Secondly, you will be given a form to enter attributes about the plant Thirdly, you submit this info to the database Fourth, I should get a message stating it has been entered into the DB I'm working on the 3rd and fourth step. Is this what you thought I was explaining? esscher Quote Link to comment Share on other sites More sharing options...
mainewoods Posted February 26, 2008 Share Posted February 26, 2008 I see, so you're saying different forms will be displayed for some different vegetables. While you can't execute stuff between the script tags by innerHTML'ing it, if you have an event attached to the form you innerHTML, it will execute when you submit the form: <form name="myform" action="" onsubmit="functionname(); return false;"> the 'functioname()' function would have to be already defined in your main page in the HEAD section. You should be able to create a generic one that would work with all your different vegetable forms and submit the form values through ajax. You probably will want to create different php pages to be called for step #1 and step #3. Step #3 would return the message to you in step #4 telling you whether the action was successful or not. Quote Link to comment Share on other sites More sharing options...
esscher Posted February 27, 2008 Author Share Posted February 27, 2008 That makes sense. I'll have to work on it, but I see how it could work. I'll update again when I have made some progress Esscher Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.