Returning Multiple Values Using XMLHTTP Object?
Apr 6, 2006
I'm just starting to try out "Ajax" web programming and I've got a question.
AJAX is fairly straightforward. Javascript creates an XMLHttp object and
then uses that to generate a hidden webpage with your results.
What I'd like to know is, how can I retrieve multiple values from an XMLHttp
request?For example, if my request generated an SQL query that returned a
Name, Address and PhoneNumber, could I get those values directly instead of
parsing them out of the ResponseText?
This is my current handler:
function showResult(pge) {
var url="getResult.asp?sid=" + Math.random() + "&q=" + pge
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
function stateChanged() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
//Complete, so show results.
document.getElementById("myResult").innerHTML=xmlHttp.responseText;
//How to get mulitple values here?
}
}
View 3 Replies
ADVERTISEMENT
Mar 23, 2009
From the code given below, I think it's pretty obvious what problem I'm having, but I'll explain:
Javascript is only returning HTML DOM attribute values when they are assigned by the javascript function, not when they are assigned by CSS. So, if I set the background colour of a div using CSS, then try to call that attribute value, JS doesn't return it, BUT, if I then assign a new value using JS, it can correctly read the attribute value.
What am I doing wrong? Or can javascript not pull HTML DOM attribute values assigned by CSS?[code]...
View 2 Replies
View Related
Jan 25, 2010
We use .mac's to create some of our Web content where we also use some javascripts. We have numerous prompts where we have a button for the user to click on that brings up a new prompt window where they type in a search name like, TIE, to search for all ties available to select from.
After typing the search name, the same window displays a list of selections to choose from. When they select the desired item and click the continue button, the window closes and we return the item number to the calling program.
What I would like to do is bring back more than one variable. For example, instead of just, 1234 in Fld1, I would like to return, 1234 into Fld1 and B into Fld2, where Fld2 will not be displayed but needed elsewhere.
For this made up example, these codes could stand for... 1234=Tie and B=Blue. We may use 1234 for all ties and have a second field to further define it.
The code I have always used in the past will just bring back the 1234, I am asking how to return the B also?
Here is some of the code I currently use:
This displays the button they click to bring up the pop-up search window...
<tr>
<th Align="Left" BgColor="LightSteelBlue">Item#</th>
<td colspan="3">
<input type="text" size="5" MaxLength="5" name="choiceItem" value="$(choiceItem)">
<input type=button onClick="window.open('/member/Item_Lookup_Both.mac
[Code]....
View 3 Replies
View Related
Jan 19, 2010
I've been trying to create a 'loading page' for a from. When a user submitts a form, a loading animation is displayed on the page. Then I have javascript connecting to a url on my server that generates a dynamic file and returns it from memory. My problem is that I can display the text from this new file, but what I want to do is prompt the user to save the file locally. Is there a way to make this sort of conversion in javascript?
View 1 Replies
View Related
Mar 28, 2011
So, my url looks like index.php?id=2&name=test&place=14
There is a next link that uses an onClick= to call an ajax function. This ajax function runs this php script (bar_next.php) behind the scenes.
I need to put just the id value into the code below.
xmlhttp.open("GET","bar_next.php?id=URL VALUES GO HERE",false);
View 5 Replies
View Related
Jan 2, 2008
Say x in a XML Http Request Object ... meaning it's either XMLHttpRequest (firefox) or ActiveXObject (IE)
This line of code works in firefox...
x.someProp = "someValue";
alert(x.someProp);
But in IE I get "Object doesn't support this property or method" I need to place a custom property on the object. Is there any way I can do that in IE?
I've already tried ActiveXObject.prototype.someProp = "";
View 1 Replies
View Related
Aug 10, 2005
alert(xmlhttp.responseText);
gives a system error number: -1072896658
I have declared the object using:
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
It works with IE version 6.0.2600 but not with IE version 6.0.2800
Couldnt find wat tis error code 1072896658.
View 4 Replies
View Related
Feb 26, 2006
I am trying to populate two select boxes with over hundred option elements for each. I have succeded in doing so but with a little problem. I make two xmlhttp calls one after another. What happens is that if the first call doesn't make it before the second, the data in the first select box fails to load and the second box succesfully loads data. I am new to the Ajax world but i am sure i am not doing it right.
View 4 Replies
View Related
Feb 4, 2010
I am currently working on a function that will allow the user to search for an event by date and category. I've been using the w3schools exercise as an example but i wish to pass 2 pieces of data instead of one and am not sure how to do so. I'm sure similar posts have been raised before and i apologise if this type of question has already been answered but i could't find it in the forum index.
<FORM name="myForm">
<INPUT type="text" readonly name="MyDate2" value="Click for Calender" onClick="toggleCalendar('MyDate2')"size="15">
Select a Classification:
<select name="Classification2">
[Code]...
Even just point me in the direction of a good article or tutorial, i've been banging my head against it for 2 days so i'm very willing to take a few hours to go through a tutorial
View 9 Replies
View Related
Mar 27, 2007
I am trying to turn all the bullet points Li id values so i can store them.. I have written the code below but all this does it return the number of li's, everything i have done to bring out the id of the li, it fails. Code:
View 2 Replies
View Related
Jul 23, 2005
Ive been banging my head on the wall for hours with this one, hopefully
someone will know what Im doing wrong here :
The Goal:
I have an xml file that is generated on the fly via JSP which I want to
load into a Microsoft.XMLHTTP ActiveX object and manipulate via
javascript on the client side. Data is retreived from the server at the
request of the javascript without having to reload the page.
The Problem:
For the JSP to dynamically output xml, the file must have the extension
JSP, which is set to the mime type of dynamo-internal/html on the
server side (as we are using ATG Dynamo). But the javascript on the
client side will not retrieve anything unless the file extension is
..xml (or the mime type is recognized as text/xml). So the only way I
can get it to work is to change the extension to .xml, which then of
course amkes it so that the server will not process any of the JSP
code.
Ive tried to override the mime type within the javascript, using the
setRequestHeader method after opening the file, but no luck. A call to
alert the value of req.responseXML.xml after the send() turns up empty.
Ive only gotten it to work if I use a static xml file in palce of the
jsp. Sample of the javascript code is below:
if (window.XMLHttpRequest) {
// branch for native XMLHttpRequest object - THIS WORKS
req = new XMLHttpRequest();
req.overrideMimeType("text/xml");
req.onreadystatechange = processReqChange;
req.open("GET", "models.jsp?cId=300006&mId=TAC24", true);
req.send(null);
alert(req.responseXML.xml); //this gives me the resulting xml file
} else if (window.ActiveXObject) {
// branch for IE/Windows ActiveX version - NOT WORKING
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", "models.jsp?cId=300006&mId=TAC24", true);
req.setRequestHeader("Content-Type","text/xml");
req.send();
alert(req.responseXML.xml); //this gives me nothing
}
}
In looking at the following example the Microsoft gives (bottom of
page):
http://support.microsoft.com/defaul...B;EN-US;Q290591
I just dont see what could be going wrong here.
I should note that I successfully got the script to work using the
XMLHttpRequest object and the overrideMimeType() method. This works
with FireFox and I think some Mozilla clients, but not with the all
important IE5, which instead uses the XMLHTTP ActiveX control.=
View 2 Replies
View Related
Sep 1, 2011
My getElementsByTagName ("a"); is not returning anything. (well it's returning "0" not the value I should be getting) I'm asking it to find the number of links on my simple html page. (the reason I'm even doing this is just because I'm trying to learn javascript) but the console in Firefox and the Alert window are just returning "0" when it should tell me I have "4" right?
the files are both located in the same folder, locally
this is my scripts.js file
Code:
var linksAmount = document.getElementsByTagName("a");
alert("Amount of Links:",linksAmount.length);
console.log("Amount of Links:",linksAmount.length);
and this is my html file (it's very small)
[Code]....
View 2 Replies
View Related
Aug 28, 2010
im having a problem with returning the value of a custom prompt box function . and stopping anything from happening while the prompt is open... the problem is with the
Code:
alert(prompt('please enter your name'))
at the end
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<style type=text/css>
[Code]....
View 4 Replies
View Related
Mar 7, 2006
Need some help with my For loop. The issue is that, my loop is only returning the values of the last item in the js file. I want the select box to include all possible names.
Code:
View 1 Replies
View Related
Jan 24, 2011
I want to open a aspx page as popup at a button click with some text box values being passed toit. Also need to display data in a grid in popup and then when a row is selected send that data back to parent .
View 1 Replies
View Related
Feb 25, 2011
I have the hover event set up. There are 100 elements in my document of the class square. What I want to do is return the ID of the current square that is hovered and edit the style=' ' attribute of the .square with that specific ID.
[code]
<script type="text/javascript" src="jquery-1.5.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
[Code]......
View 2 Replies
View Related
Aug 24, 2009
Basically what I'm trying to do is write a plug in which connects to a sharepoint web service, traverse the results of the xml document that is returned by the web service for certain elements, and then return a collection of xml elements which I can use in another function on the page that is calling the plugin.My code looks like this:Main Page
<script type="text/javascript">
$(document).ready(function() {
var listItems = $.sharepoint();
[code]....
View 1 Replies
View Related
May 27, 2011
I'm doing some jquery and ajax work with C# asp.net MVC on the server.
I have this JS function:
function DeleteListing(receiptItemId){
$.ajax({
url: "DeleteListing",
type: "POST",
[Code].....
What I'm wondering is there ways to return values from DeleteListing on the server to the success function?
View 4 Replies
View Related
May 28, 2010
jquery width() and height() functions are consistently returning the wrong values for the viewport size (i.e. $(window).width). Anyone know why..or what I can do to fix it?
View 3 Replies
View Related
Dec 13, 2007
I'm using height() and width() to find the dimensions of some inline images in the html. FF and IE work fine, but Opera is returning incorrect values. For example, it returns 92px as the width of an image that is actually 160px wide. How can I fix this?
View 4 Replies
View Related
Aug 5, 2009
I have a very simple PHP script that returns JSON like this:
{"question":"What day is it?"}
And I'm trying to call it from another page using Ajax. My code looks like this:
var url = "/test.php";
$.get(url,
function(data){
$.each(data, function(i, value) {
alert(value);
}, "json"
);
});
When I run it I get each character printed out one at a time in a separate alert. And then when I used this line of code:
alert(typeof data);
It tells me that 'data' is a string. Shouldn't it be a JSON object?
View 6 Replies
View Related
Nov 7, 2011
I've been going through the documentation for the deferred objects API, and one thing that's still not clear to me is : what jQuery functions are returning a deferred object?
The documentation seems to say that jQuery.ajax() and the animation functions like jQuery.fadeIn() does (what about jQuery UI effects?), but the pages for those functions say they return a jqXHR object and a plain jQuery object.
[Code]...
View 4 Replies
View Related
Oct 9, 2010
I have the following code:
A = {
"value": "a",
};
B = A ;
B.value = "b";
alert (A.value); // => b
I expected A.value to be "a". how can I change values of a new object, without changing the parent-object?
View 6 Replies
View Related
Jul 19, 2011
I have a list of products where they have minimum quantities in a hidden input. Some products have multiple colours, though the same minimum quantity and I'm trying to implement a jQuery check that entries made are at least equal to the minimum.
Blank or '0' entries are fine but if it's below the minimum quantity it should set to the minimum.
HTML:
Is there something obviously wrong with this? It isn't performing the minimum check and I'm really not sure why.
View 1 Replies
View Related
Mar 19, 2009
I am setting up a text search with 3 search buttons to allow 3 different searches from the one text box. Each search has different values for the 2 hidden elements. So far I've got the 3 submit buttons working with the below code but I can't figure how to get the hidden values to be inserted. For each of the 3 different submits I need to tell javascript what the 2 hidden values are.
<SCRIPT language="JavaScript">
function OnSubmitForm()
{
if(document.pressed == 'questions')
{
[Code]....
View 4 Replies
View Related
Aug 25, 2010
I am trying to get the index of a li with a specific class. I know I'm selecting the right object because I can apply a CSS class to it (eg change border colour) but when I try to get the index it returns -1. But I know the object exists as I can alter it. :-s
jQuery(document).ready(function() {
var active = $("#tertiarynavigation .bordered").get(0);
var num = $("#tertiarynavigation li").index(active);
alert("Index: " + num);
[Code]......
View 1 Replies
View Related