Using AJAX to get data

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Using AJAX to get data

Post by GeXus »

I'm using "AJAX" to basically get data from another php page onsubmit and return that data to the parent page.

The problem is that the page I am receiving data from, has some javascript that I need to include.. but it seems that because it is loading in a span tag or that it just simply does not support javascript...

Not sure if this is enough info, but if anyone happends to know a work around.. that would be great!
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Are you trying to include javascript code or javascript output? such as document.write output
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Im including javascript...

Basically im using this script http://www.captain.at/howto-ajax-form-post-get.php
and the "get.php" file that im using, has javascript in it... but it wont process..
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

You should prob. show some code...Have you looked into file_get_contents()?
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

hawleyjr wrote:You should prob. show some code...Have you looked into file_get_contents()?
first, file_get_contents is not what he needs. that will just confuse the him even more...


secondly, there are a number of things that would cause this to not work (and yes, I'll even state the obvious ones that you will find useless, but hey, it never hurts...)


1) You may not have php installed, or apache for that matter.

2) You may not have created the files correctly.

3) You may not have javascript enabled on your browser.



I say this because the example on the URL you gave works exactly how it is suposed to.

The thing that you may doing wrong is you may not be creating the new DOM element (or span tag) correctly, and thus it will not be available for javascript to deal with.

As was stated above, please show us your code. 9 times out of 10 it is probably just a small typo. Usually if it was a problem with the xml request object, it would have generated an error (that is of course if error reporting was properly written for the functions..).
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

No, the code on that page works perfect... Everything works just as it should from the given example. The problem is that the content I am retreiving has javascript within it.. and THAT javascript will not work.. because it is being loaded through HTTPxmlrequest, so im wondering if there is a way so that it will except and parse the javascript that is being loaded from the "get.php" page...
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

GeXus wrote:The problem is that the content I am retreiving has javascript within it.. and THAT javascript will not work.. because it is being loaded through HTTPxmlrequest, so im wondering if there is a way so that it will except and parse the javascript that is being loaded from the "get.php" page...
You might need to eval the javascript that you load. It depends on the browser and to what kind of visiblity you get based on the order things are loaded. There was some discussion about here in this thread that pointed to an article. You may want to Google something like "eval javascript HTTPxmlrequest,"

Obviously you want to be very paranoid about evaling loaded javascript,
(#10850)
Post Reply