Jump to content

javascript in ajax opened url


esscher

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.