Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    JavaScript


Javascript In Ajax ResponseText

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:

function test(){

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 (Posted: May 1, 2006, 12:32)

Sponsored Links:

Related Forum Messages For JavaScript category:
Ajax :: Response.responseText Adds Previous ResponseText (node.js, Prototype)
This is my node.js function that uses res.write:

function: ping(){
setTimeout(ping, 30000);

This is the client, request written in prototype:

this.pushconnection = new Ajax.Request(pushserveraddress, {
method: 'get',
evalJSON: 'false',


I'm not sure if node.js is re-sending the data, or if prototype is storing the data. What I need to do is have response.responseText = the last data sent without using res.end();

Posted: Sep 2 11 at 18:53

View 1 Replies!   View Related
AJAX :: ResponseText Not Getting Anything?
I wrote this simple AJAX script:

var request;
function createRequest(){
request = null;


I used firebug to check the response i was getting from server. Its absolutely fine and is of type "text/html".

Posted: Jul 19 10 at 20:05

View 2 Replies!   View Related
Ajax :: ResponseText Comes Back As Undefined
I'm having problems with this piece of code; the return value comes back as 'undefined'.

var fx = null;"GET", URL ,false);
xmlhttp.onreadystatechange=function() {
alert("enter func");
if (xmlhttp.readyState==4) {
if (xmlhttp.status == 200) {
fx = xmlhttp.responseText;
return fx;
alert("Error" + xmlhttp.statusText);

Newer code:
function getData(callback){"GET", URL ,false);
if (xmlhttp.readyState==4){
if (xmlhttp.status == 200){
alert("Error" + xmlhttp.statusText);

How I'm calling it:
getData( function cbfoo(txt){

Posted: Jan 12 11 at 18:48

View 1 Replies!   View Related
Ajax :: Return Only Part Of Responsetext?
The below is just a bit of my ajax code, at the moment my variable 'resp' is returning an entire response from test.php. Is there any way I can just return the responseText between a specified tag? ie. just get back the responseText of the html inside test.php's div of id="xyz"?

var loc="test.php?myinput=apple";
ajax.onreadystatechange=function() {
if (ajax.readyState==4 && ajax.status == 200) {
var resp = ajax.responseText;

Posted: May 10 at 12:50

View 4 Replies!   View Related
Returning Array From Ajax.responseText?
if it's possible to return an array from my php generated content to ajax's responseText. I tried echoing back the whole array variable but can't seem to fully receive it in javascript.

somewhere in file1.php

$myArray = array();
$myArray['name'] = "ajax tech";
$myArray['age'] = 20;


Posted: Nov 28th, 2007

View 9 Replies!   View Related
AJAX :: Unable To Test ResponseText
My PHP code responds to AJAX call with different strings, depending. so I want to test the response, but I haven't been able to do it. I found that the responseText was of undefined type so tried type casting [code]...

Posted: Nov 12 11 at 21:13

View 1 Replies!   View Related
AJAX :: ResponseText Is Undefined After GET Request To .php?
I'm trying to pull a list of devices from a mySQL db, which I then format into an html select/option element in my .php and then I echo the string of html to insert into my main page, but it won't return the string I echo to the responseText.Here's my .php:

$dbhost = "localhost";
$dbuser = "root";


Posted: Jul 25 11 at 20:44

View 1 Replies!   View Related
Ajax :: Get Element By Id From Responsetext Without Printing It Out First?

i need to get the "100" out from the id "someid" tried using this alert(xmlhttp.responseText.getElementById('someid').innerHTML); but it doesn't work.

Posted: Nov 4 11 at 3:56

View 1 Replies!   View Related
Ajax :: Can't Retrieve ResponseText From Servlet
I have a servlet file called This servlet is called by my AJAX script to retrieve the response.

I have verified the servlet by testing it in a browser.

But when I call it from my AJAX script it gives me a blank responseText and an error that says

import javax.servlet.*;


Posted: Apr 25 11 at 17:24

View 3 Replies!   View Related
Ajax :: Reverse The ResponseText Detection?
This function gets called when an ajax requests readyState == 3,

function(context, xhrobj, itself){
//Test if context.responseText is available here.
var text = context.responseText;
//Do stuff

How would I be able to test if context.responseText is available? I am currently doing this,

if ($.browser.msie) return false;

But I really don't want to do browser detection, Is there a way to detect if context.responseText is unavailabe? Specifically for IE7/8, I am not supporting 6 or below.

I've tried,

if('responseText' in context) return false;

which doesn't work because it is in context, just not available, and

try{context.responseText;} catch(x){return false;}

but this seems like a hack.

Posted: Jan 18 11 at 18:16

View 1 Replies!   View Related
Ajax :: Replacechild - Extra Tag Added To Responsetext
I do not want the outer div tag? how to i add my responsetext with its codes only. This is working, but the result is not what i wanted.

var newdiv = document.createElement("div");
newdiv.innerHTML = xhr.responseText;
document.getElementById("middleright").replaceChild(newdiv, document.getElementById("moreoption"));

middleright is the parent of moreoptions. after this is executed, middleright becomes the parent of div instead of the responsetext. i tried doing this.

document.getElementById("middleright").innerhtml += xhr.responseText;

This is what i'm looking for, but it only inserts to the end of the innerhtml, i want to insert it in the middle. Is there any alternative?


Posted: Sep 29 10 at 15:30

View 1 Replies!   View Related
Ajax :: .replace Not Working On Xmlhttp.responseText
I have:


I try that, and the replace just doesn't happen. When I change cur to just have a value of normal text (cur='my name is....';) then it works fine. I've tried changing the replace line to: cur=cur.replace(cu,'found it'); - still nothing This is all in the same function as the where the AJAX request takes place...

Posted: Dec 5 11 at 18:26

View 3 Replies!   View Related
Ajax :: Return Xmlhttp.responseText From Function?
I've been racking my brain for a couple hours now and doing a lot of searching and I cannot seem to find an answer. I want to know if it is possible to return the xmlhttp.responseText value from an AJAX function to the function that originally called the AJAX function.

//Set handler for server response.
xmlhttp.onreadystatechange = function()


I want to return the my_response variable to the original caller. No matter what I try I have been unsuccessful. I even tried assigning it to the global window variable using window.my_response = xmlhttp.responseText but it ends up being undefined.

Every example I've seen of using AJAX pretty much does something inside of the if (xmlhttp.status == 200) part to update the web page. I really do not want to do that.

Can I return the value?

Posted: Jun 9, 2011

View 4 Replies!   View Related
AJAX :: ResponseText Always Return Null In Firefox?
Below is JS code:

var request = new XMLHttpRequest();"GET", "\");
request.onreadystatechange = function() {
if (request.readyState == 4) {


using above code, I wanna implement uploading/dowloading/parsing file with json format. however, the responseText always return null in FF. It it about to make me crazy.

Posted: 07-30-2010, 02:00 AM

View 1 Replies!   View Related
Ajax :: ResponseText Null In Internet Explorer?
I have some simple ajax code. All I want to do is load a php page into a container but in internet explorer I get the error: SCRIPT5007: Unable to set value of the property 'innerHTML': object is null or undefined. Which means that internet explorer sees xmlhttp.responseText as null. It does this with any way I have tried to get the ResponseText. Heres my code:


Posted: Mar 12 11 at 19:02

View 1 Replies!   View Related
Jquery :: Ajax - WebService ResponseXML / ResponseText?
I get an empty response back from this local WebService call via jquery / ajax. I have verified the URL and XML input string by invoking the call in a browser. I DO get XML code back as expected.

What am I missing? Could it have something to do with the return type "XmlDocument"? I have tried changing out text/xml to text. No affect. Tried a GET instead of POST.


Posted: Apr 29 10 at 6:19

View 1 Replies!   View Related
AJAX :: Read Data From Server Using XMLHttpRequest.responseText?
I am trying to read data from server using AJAX XMLHttpRequest.responseText.In received data, there are lot of similar type of characters which has tge value of FFFFFD (65533). I think, all characters which has the value above 127 are converted to default character.

Posted: March 20th, 2009, 03:22 AM

View 1 Replies!   View Related
Ajax :: Responsetext From Page Not Displaying In Intended Position
Im my code i get a value from an ajax page , but it is displayed in a different position than i wish to display.I had used document.getElementById('ajaxhide').innerHTML=xmlhttp. responseText; inside javascript properly also.The ajax value returned is like this echo '<td>'."Thanks".'</td>';

Posted: Jul 15 11 at 19:00

View 1 Replies!   View Related
Ajax :: Pass ResponseText From Asynchronous Call To Another Function?
I'm using jQuery and countdown (jQuery plugin). I want the countdown to run for x seconds, where x is an integer from serverTime.php.

Problem - I can't figure out how to return the responseText in function getTime(), so that it could be used in Timer function.

At first I tried using pure js (without jQuery), and I found similar topics:

why-can-i-not-return-responsetext-from-an-ajax-function in-ajax-how-to-retrive-variable-from-inside-of-onreadystatechange-function how-to-return-variable-from-the-function-called-by-onreadystatechange-function and others...

Some ideas/possible solutions I've come across:

using synchronous call and a global variable for storing response. I tried this and don't consider it an option, because it freezes the user screen (and is considered bad practice as well, in most cases) helper function .

Timer function:

$(function (){
var time = getTime(); // time is an integer
$('#defaultCountdown').countdown({until: time, format: 'S', onExpiry: action});


I've tried to explain my problem and show that I've put some time into it. If you need additional information, just ask.

Posted: Jul 16 11 at 18:36

View 2 Replies!   View Related
Ajax :: Page Scroll Bar Freezes While Div Is Updated By It ResponseText / Fix It?
I'm using jQuery's $.ajax() to send Ajax request to server and bring back a large chunk of HTML content to replace the content of a div. Everything works fine except for the problem that while the div is being updated, the page is kind of frozen (even the vertical scroll bar is not draggable). It comes back to normal after the div is updated.

Posted: Jul 26 11 at 0:39

View 2 Replies!   View Related
Jquery :: Ajax Call Errors In Chrome On Enter With No ResponseText
I've built a login page that uses a .ajax call to a generic c# handler (.ashx) to validate the username and password before allowing the user to log in.

If you click on the login link

<a href="#" class="ui-state-default ui-corner-all CustomButton" onclick="goLogin();return false">

the .ajax call returns successfully and it logs the user in. I am trying to make it so the user can also just press the "enter" key from the password box:

$("#pword").keydown(function(e) {
if (e.keyCode == 13) {

Using Firefox, both ways work just fine and the user is logged in. With Chrome however, pressing "enter" hits the error function of my .ajax call and will not log the user in.

The parameters and responses look identical through Firefox's console, as expected.
What would be causing this and/or how can I debug it in Chrome?

Posted: Feb 4 10 at 21:44

View 3 Replies!   View Related
Ajax :: Avoid Echoing Character 65279 In Php (xmlhttp.responseText)
I have encountered a similar problem described here (and in other places) - where as on an ajax callback I get a xmlhttp.responseText that seems ok (when I alert it - it shows the right text) - but when using an 'if' statement to compare it to the string - it returns false. (I am also the one who wrote the server-side code returning that string) - after much studying the string - I've discovered that the string had an "invisible character" as its first character. A character that was not shown. If I copied it to Notepad - then deleted the first character - it won't delete until pressing Delete again.

I did a charCodeAt(0) for the returned string in xmlhttp.responseText. And it returned 65279. Googling it reveals that it is some sort of a UTF-8 control character that is supposed to set "big-endian" or "small-endian" encoding. So, now I know the cause of the problem - but... why does that character is being echoed?In the source php I simply use echo 'the string'... and it apparently somehow outputs [chr(65279)]the string...

Posted: Jun 30 11 at 16:45

View 3 Replies!   View Related
AJAX :: Internet Explorer: Setting InnerHTML To Xmlhttp.responseText Fails
document.getElementById("livesearch").innerHTML=xmlhttp.responseText; //fails on IE: "Unknown runtime error". Line & character index is for the start of the word document. Works in Firefox. document.getElementById("livesearch").innerHTML="Something special"; //works alert(xmlhttp.responseText); // works on IE (done as a debug test) Target of "livesearch" is a <div id="livesearch></div> block

Posted: Mar 31 11 at 17:58

View 2 Replies!   View Related
Using Ajax.Request Response Inside Of An Object - PrototypeJS - Pass The Transport.responseText To The Objects This.rezultat Variable
for past two hours i've been trying to pass responseText to the object i'm calling Ajax.Request in. And it just isn't happening :) Here's the code;


So, what i need is to pass the transport.responseText to the objects this.rezultat variable.

Posted: Oct 9 09 at 8:40

View 1 Replies!   View Related
Copyright 2005-08, All rights reserved