AJAX, Eval(), And Javascript Within Javascript

Apr 28, 2006

Ok so, this is my purpose:
- to be able to load asynchronously (via AJAX) some javascript ads (like google's or adbrite) so as to make them be loaded in the background, then update the page after the ads have loaded via innerHTML

Why?
-Because 90% of the time in my newer sites, javascript ads are the major offender in terms of speed of page rendering

My problem:
Via ajax, I can call a php file that retrieves some javascript and outputs it, XMLhttprequest returns those javascript lines, but they don't render in the page, since they miss the whole page loading, and are apparently not parsed
For example, let's say I call a php file via ajax, and it returns the output into a variable named "text" containing "document.write('hello')"
if I use xxx.innerHTML=text, nothing happens

My 1st solution:
Passing those javascript lines to eval() [like eval(text) ], but this produces a second problem, that I couldn't solve (probably because of my lack of knowledge in javascipt):
if I eval the code, it deletes my current page and renders a new one
for example, if I parse a document.write, my page disappears, and a new one is rendered with the document.write text

What I want is basically to make that "document.write" appear inside a div in my page, adding to the content (and not overwriting the whole page), much like what happens when using innerHTML

Is this even possible? How would you go about it?
I tried xxx.innerHTML=eval(outputfromphpfile) but it overwrites my whole page...

View 3 Replies


ADVERTISEMENT

Javascript Eval

Feb 2, 2006

I am trying to do the following but i get an error, is there no way i
can use eval to print have it assigned to a predeterminded variable.

eval (object_name + "_CalCalendar") = new CalendarPopup(object_name);

Cannot assign to function result.

View 2 Replies View Related

Javascript + Firefox + Eval()

Jul 29, 2004

I have a script that uses eval() and it works great under IE but it craps out when eval() is called in firefox. Just ignore all the commented out alerts, it is for testing purposes. Code:

View 2 Replies View Related

Using Eval() With Ajax Response

Apr 3, 2008

I am wondering how possible it is to use eval() to parse javascrpt that is pulled in through ajax(innerHTML)? I have found a few notes about this, such as:

Code:
var myObj = eval ( xmlhttp.responseText );

View 14 Replies View Related

Get And Eval() Inner In Script Tag From AJAX Call?

Oct 26, 2011

I have an AJAX call to a data grid. The datagrid is authored by Advanced Power of PHP [URL]

I don't want to get crazy and modify the data grid to give me different responses back but rather when it sends a response like this back to the browser via AJAX:

HTML Code:
<form name="frmPagingUpper" id="frmPagingUpper" action="" style="margin: 0px; padding: 5px;"><table class="blue_class_paging_table" dir="ltr" style="margin-left: auto; margin-right: auto; width: 90%;" border="0"><tbody><tr><td class="class_nowrap" align="left"></td><td class="class_nowrap"

[Code]....

View 4 Replies View Related

JQuery :: Eval Fails In Ajax Call?

Dec 4, 2010

I'm working on a weather api. A call to an internal PHP page GETs XML and returns JSON. However, I cannot get it to evaluate as an array:

(function($){
$.ajax({
type: "GET",
url: baseUrl + "weather_data/get_forecast",

[Code]....

Firebug (FF 3.5) displays the response in the JSON tagged perfectly parsed, but the code above fails.

View 1 Replies View Related

Ajax Firing Off Javascript

Feb 8, 2006

I am using Ajax to refresh a DIV area by setting the
innerHTML=request.responseText in the usual manner. in the response text I
have a <SCRIPT> tag in line, but this is not executed. Is there a way of
making the ajax refresh process this.

View 11 Replies View Related

Ajax But Disable Javascript

Apr 12, 2006

If the browser disable the javascript, what happen to Ajax? can i slove
the problem by using server side script? any suggestion for this?

i currently do some dirty projects with perl/cgi, and I would like to
add more client side features which relate to ajax, and do some
validation on the client side with javascript. but it is possible that
the javascript may be disable with some browsers. what can i do if the
client's broweer disable the javascript.

View 8 Replies View Related

What Is The Differences Between AJAX And JavaScript?

Jul 26, 2006

Is AJAX built on top of JavaScript? What browsers supported AJAX?

View 6 Replies View Related

Getting Started With Javascript And AJAX

Aug 30, 2006

I'm interested in learning Javascript with an eye towards using it for
client-side user interfaces for web services, and I have a couple
questions.

First -- In reading some of the archives here, I've noticed a fairly
strongly held opinion that it is better to write purpose-built
Javascript than to use large libraries. Since this was what I was
planning on doing anyway, because of the size of the libraries and
compatibility quirks with Safari, it's nice to hear confirmation from
experts. That said, is the code in Prototype, Scriptaculous, and
OpenRico good enough to be worth reading and emulating?

Second -- I do much better with dead-tree references than with the
web, especially as a lot of the links that come up when I google for
Javascript topics are tutorials for the clueless by the clueless.
(Perl has the same problem, but with Perl I have enough knowledge to
filter the useful bits from the flat-out wrong bits.) Aside from the
O'Reilly Javascript reference (which I have) and _Ajax Hacks_ (which I
also have), are there other good references I should get my hands on?

View 1 Replies View Related

JavaScript As AJAX Response (RPC)

Oct 15, 2006

Some servers return JavaScript as the response to an AJAX request. When
the response JavaScript is eval'ed it calls other JavaScript functions
already in the browser to update elements, etc. This seems like a good
system because it allows so much freedom in creating the desired
behavior in the browser. The required data doesn't have to be converted
to XML or JSON on the server. The browser doesn't have to have
templates for interpreting and converting this data into some change in
the browser. All of the conversion algorithms don't have to be written
and changed when new behavior is required. This remote procedure call
approach is the predominant system in the Ruby on Rails world.
(Unfortunately they are calling Prototype.js functions.)

However apparently some people seem to think this remote procedure call
approach is a bad idea. I can't see why it is so bad because it is so
lightweight and flexible. It also helps to keep the client less
intellegent which seems good in a world of incompatible client-side
bugs.

If I use some neutral data format like XML to accomdate different types
of clients then I have to write different client-side interpreters for
each type of client (browser, RSS, POP, cell phone, etc). Why not just
write different server-side code that generates the correct JavaScript
(or other) for the requesting client type?

When is the RPC approach such a bad idea?

View 5 Replies View Related

Javascript In Ajax ResponseText

May 1, 2006

I'm making an ajax call to return the contents for a page using the responseText property. I want to be able to define a javascript function in the page and call it, doing something like:

<script>
function test(){
alert('hi');
}
test();
</script>

However, none of the javascript in my page works. I'd imagine it has something to do with it being included as part of the responseText and the browser is not picking it up. I haven't been able to find any info about this online anywhere. Any thoughts?

View 7 Replies View Related

Encrypt Javascript/ajax

Sep 28, 2006

Is any way to encrypt the javascrypt code ?

View 3 Replies View Related

Java Vs Javascript For AJAX?

Jan 19, 2007

I am a XHTML/CSS developer with an interest in AJAX. I am at the stage were I wish to learn how it's all done.

So my quesiton is this:

To develop AJAX applications do I need to learn JAVA or Javascript?

It may sound like a dumb question considering AJAX is mainly javascript and XML, however will learning JAVA first off be a benefit?

View 4 Replies View Related

Javascript On AJAX Request

Feb 16, 2007

I am currently creating a social network. On a profile if a user has comments they can delete them. I am running AJAX to update the database and display the comments refreshed (one deleted will no longer show). The data I am requesting includes the following...

<script language="JavaScript">
document.write("<a href="javascript:void(0)" 'CommentsTable', 'PostLink1', 'PostCommentText', 'ViewCommentsText')" id="PostLink1">Post Comment</a>");
</script>
<noscript>
<a href="comment.php?action=post&user=<?php echo $user; ?>">Post Comment</a>
</noscript>

My problem is that the JavaScript from the request does not work, I can only seem to display regular HTML. Is there a solution to this problem to make the JavaScript work or do I have to use an HTML alternative?

View 4 Replies View Related

Disabling JavaScript Ajax

Sep 26, 2007

If you have your site implemented in ajax, and client browser has disabled the javaScript, then ajax won't work?

Another question is, what if you are creating the page lay out(background color, boxes, etc) in javaScript, does it mean they also won't work?

View 1 Replies View Related

AJAX And Javascript Distinction

Dec 29, 2007

Is it just me, or is there no distinction between AJAX and Javascript nowadays? Today I saw a request for a calculator, something that should be done with just Javascript, but yet the post was seeking an AJAX developer. When did these terms become synonymous?

View 2 Replies View Related

AJAX :: Eval Works On FireFox But Not On Google-Chrome?

May 28, 2011

While doing simple interactive mathematical calculator for my son, i came across some issues. in the beginning i was working on Firefox 4.0.1 Fedora 15 didn't get any issue yet when i switched for google-chrome 11.0.696.68 the script didn't work anymore. i trimmed it down to simplest form possible and here i demonstrate:

<html>
<body>
<script type="text/javascript">
eval("x=10;y=20;document.write(x*y)");

[Code]....

View 2 Replies View Related

Run JavaScript That Is Part Of AJAX Response

Apr 12, 2006

In my browser, I make an AJAX request. The server sends me a fragment
of an HTML document. That fragment has some JavaScript inside some
script tags. How do I run these scripts when the fragment arrives at
the browser?

View 12 Replies View Related

Parsing Iframe's XML In JavaScript (AJAX Trick?)

Oct 3, 2006

Since XMLHTTP Request does not support loading of XML from other
servers, I decided to use a trick:

load XML into hidden iframe and then get that XML with JavaScript to
parse.

But, is this a good idea? I am stuck. How do I get XML loaded in the
iframe and pass it on to JS function for parsing?

View 11 Replies View Related

Javascript/AJAX Multiplayer Gaming Library?

Mar 15, 2007

does anyone know of any way to allow for multiplayer interaction using Javascript/AJAX calls?

I am looking at two (or more) players visiting the same webpage and interacting with one another to play a text/browser based game (non-Flashed based).

Any ideas on how to do this using JS/PHP and mySQL?

View 1 Replies View Related

Ajax :: Form Not Finding Javascript Function?

May 12, 2011

I can't seem to figure out what I'm doing wrong with this no matter how many things I try. I've looked through Google for a related issue but found nothing specificThe script runs through a external .js file calling a list of music albums, then listing the song of the album chosen via ajax. The user can then edit of delete the songs. Everything works fine until I submit the edited information through a form. When I click the submit button I get a web developer error "updateSong is not a function"Here's the form which is loaded into the already existing page via ajax:

<?php
include("database.php");
$song = $_GET['song'];

[code]....

View 2 Replies View Related

Dynamic Content Areas - JavaScript & Ajax???

Sep 29, 2005

I would like to build an HTML page that has four content areas. The first with 3 links that when clicked chage what is shown in the other 3 - and so changing the default content in these sections. The content for these sections will be contained in seperate HTML files sitting on the same server.

I understand this can be done without refreshing the page and believe JavaScript and Ajax is the best method to do this. Any advice?

View 2 Replies View Related

Overhead A Javascript Tookit A Necessary Evil For AJAX?

Feb 28, 2007

I am currently running a website for a medium sized company that has an application which relies heavily on AJAX. Currently, I am using DOJO, and it does a great job when it comes to cross-browser compatability. It comes with so many extras, and clients are forced to download these extras!! I have looked around at various other Javascript applications, and, while some vary in size, it seems that they are all quite large. Are these toolkits neccessary for a functioning ajax application? Must clients download an extra 30 - 150kb of js to use AJAX? In an attempt to solve this problem, I threw a script together with some help from the internet and an Ajax book that weighs in at 1.2kb. I would love to just throw this up and be done, but I don't have the testing capabilities to justify doing so. There are so many flavors of browsers, and I have access to only a few of them. Frustrating Don't really know what i'm asking, anyone else run into this frustration?

View 10 Replies View Related

Dynamic Content Replacement Using Ajax/Javascript/PHP

Jun 26, 2007

I'm sure some wizard will tell me this is a classic example of "piece of cake"; in which case I bow and promise to listen In case I've struck granite rock, feel free to throw questions my way and I'll tell you if I've tried it or not.

I have a file, main.php (I know this is the JS-forum, bear with me). It outputs HTML and inline Javascript functions. When the user clicks on a graphical "tab", that tab is activated, and an ajax call is made to fetch.php with some specific parameters. Once the ajax request has completed, a given innerHTML container on the now active tab is filled with the stuff that fetch.php outputs.

So far so good.

The problem is that the stuff that fetch.php outputs is partial pure HTML and partial inline javascript. And this is where it gets tricky. If I declare an inline javascript function in the returned data, Firefox (and I suspect MSIE) refuses to understand that the function is there. It simply doesn't exist (!).

Using the Web Developer add-on for Firefox, there's an option to look at "Source code" and "Generated source code". The output from these two differ in that when I view the "Generated source code", I see the dynamically inserted javascript/HTML from fetch.php, whereas viewing "just" the source doesn't.

What did I do wrong? How do I get the browser to find/accept/activate the javascript code/functions that were inserted dynamically? I cannot put them in a .js file and include it, since they need to be dynamically created, and I cannot use eval() since that executes javascript "as is", in which a function will not be executed unless called.

View 5 Replies View Related

Javascript Inside Of Ajax Created Page....

Oct 13, 2007

I've run into this a few times and have never found a way to deal it. Basically I'm building a user administration cms using mostly ajax calls to admin modules. It works great but I'm running into a huge problem that I need to figure out how to fix, (if possible).

As the title says the issue is including and executing javascript code inside a page that gets called via ajax. One specific example of the problem I'm having is creating sortable lists with scriptalacous. It works great if I access the page directly, but if I access the page using an ajax call the javascript of the page doesn't seem to fire.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved