473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to pass an http.responseText;

Hi sorry for writting just like that but i have a quiestion simple for people whoo know's what they are dooing here is my function

function SumaCorectaDePariere()
{
NumarMeciuri();
GetSuma();
if ( (miza<1) ) { alert("Miza trebuie sa fie mai mare decat 1 RON"); return true;}

if ( (miza>3) ) {
http=getHTTPObject();
http.open("GET",link_ajax+"verific_miza.php?miza=" +miza, true);
http.onreadystatechange = function() {
if (http.readyState == 4) {
var textout = http.responseText;
var vad=textout.split(":");
vad2=new Array();
if ( (vad[0]=="peste") ) {alert("Miza trebuie sa fie mai mica decat "+vad[1]);
return true;}
}
}
http.send(null);

}
return false;
}


all i need to do is that the "if(miza>3)" to retunr true just like "if ( (miza<1) )"
but don't know how too pass variable vad to mother function and test it or how to return true to mother function
Apr 15 '07 #1
3 4586
acoder
16,027 Expert Mod 8TB
Declare a global variable and set that within the function where you test vad.
Apr 16 '07 #2
Hi thank you fot timp it's working but i've allready done that the problem is if you notest this is a funtion witch is called by another funtion and in the first call it returns me that the var "my var " is undefined but if click ok on alert and press enter again (means try again) it returns me the good number
how can i put it not to bee undefined ?it's important because tis is an interfation with client and for every client i have to hit twice enter ill give you the funtion again
function SumaCorectaDePariere()
{
NumarMeciuri();
GetSuma();
if ( (miza<1) ) { alert("Miza trebuie sa fie mai mare decat 1 RON"); return true;}

if ( (miza>3) ) {
http=getHTTPObject();
http.open("GET",link_ajax+"verific_miza.php?miza=" +miza, true);
http.onreadystatechange = function() {
if (http.readyState == 4) {
var textout = http.responseText;
var vad=textout.split(":");
verde=vad[1];
//if ( ((vad[0]=="peste")) && ( (vad2 <= 200) )) { alert("Miza trebuie sa fie mai mica decat "+vad[1]+" va rog cereti aprobare la sediu!!!"); return true;}
}
}
http.send(null);
}

var vad2=parseFloat(verde);
if ( ( miza> vad2 ) ) { alert("Miza mai mare de:"+ vad2+" RON nu este permisa "); return true;}

return false;
}

i'm thinking of writing my var "verde" into a div somewhere and then read that div do what i supose to do
Apr 17 '07 #3
rpjd
25
Hi thank you fot timp it's working but i've allready done that the problem is if you notest this is a funtion witch is called by another funtion and in the first call it returns me that the var "my var " is undefined but if click ok on alert and press enter again (means try again) it returns me the good number
how can i put it not to bee undefined ?it's important because tis is an interfation with client and for every client i have to hit twice enter ill give you the funtion again
function SumaCorectaDePariere()
{
NumarMeciuri();
GetSuma();
if ( (miza<1) ) { alert("Miza trebuie sa fie mai mare decat 1 RON"); return true;}

if ( (miza>3) ) {
http=getHTTPObject();
http.open("GET",link_ajax+"verific_miza.php?miza=" +miza, true);
http.onreadystatechange = function() {
if (http.readyState == 4) {
var textout = http.responseText;
var vad=textout.split(":");
verde=vad[1];
//if ( ((vad[0]=="peste")) && ( (vad2 <= 200) )) { alert("Miza trebuie sa fie mai mica decat "+vad[1]+" va rog cereti aprobare la sediu!!!"); return true;}
}
}
http.send(null);
}

var vad2=parseFloat(verde);
if ( ( miza> vad2 ) ) { alert("Miza mai mare de:"+ vad2+" RON nu este permisa "); return true;}

return false;
}

i'm thinking of writing my var "verde" into a div somewhere and then read that div do what i supose to do
With regard to responseText, I am executing a php script via an xmlhttprequest, and up until now when I ran this code
[
Expand|Select|Wrap|Line Numbers
  1. response = http.responseText;
  2.     alert(response);
  3.  
all I was getting was the php code from the script. I realised that the script was not getting executed by the request. Today I moved all my files to another folder, now when I execute this code I confirmed that the script did execute and I got the results I wanted within the alert. Now I am trying to get this info out of responseText. I have tried all of these
Expand|Select|Wrap|Line Numbers
  1. split()/eval()
  2. var variable = getElementByID/Name('variable');
  3.  
and getting the same result everytime
"object doesn't support this property or method"
I am not using XML.
Can anyone help me with this?

rpjd
Apr 23 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: David Lozzi | last post by:
Howdy, I wrote a web service in .Net for my customer. My customer has another vendor who now has to consume it but they are not using Visual Studio. Most of their pages are jsp, and they said...
1
by: rpjd | last post by:
I am completely new to this so please bear with me here. My project involves a webpage executing php scripts via an xmlhttprequest which queries a database and returns data to the webpage. This code...
4
by: -Lost | last post by:
For example: var newlines = 'a\n\nb\n\nc'; alert(newlines); Yet, if I get that *exact* same line from an XMLHttpRequest's responseText, it is always alerted as: a\n\nb\n\nc
6
by: lazukars | last post by:
Hi, I am attempting an ajax request. I am using PHP serverside. Below is what the response text should be. ajaxRequest.responseText ="{username_is_taken : "This username has been taken",}" ...
5
by: JohnDriver | last post by:
Hi, I am having a form which has a text box and 3 radio buttons. I am using GET method in Ajax to pass the value. I can pass the value of the textbox fine but how to pass the value of radio...
5
by: wendallsan | last post by:
Hi all, I'm running into a situation where it seems that JS stops executing as soon as I call an eval in my script. I have an Ajax.Request call to a PHP page that builds a JS object and returns...
4
RamananKalirajan
by: RamananKalirajan | last post by:
Hi All, I am using Ajax inorder to retrieve a data from the db which is an xml and i am parsing the responseText into an xml. the code what i had tried is working well with IE, but the...
2
by: trpost | last post by:
Is it possible to execute javascript as passed in xmlHttp.responseText Here is what I am doing: search.js var xmlHttp xmlHttp=GetXmlHttpObject() var url="search.php"...
1
by: kkshansid | last post by:
i want to pass both variables($q1 and value of select) from this php page to java script so that i can get both variables in second php file srt.php <script type="text/javascript"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.