AJAX Multiple Replacements?

May 16, 2006

I have a background process that fetches XML data from various sources that can take up to 20 seconds to process.

I want to have AJAX fetch an XML file (generated by php which queries mysql) every 5 seconds and update the prices against each item. Most of the examples i have seen online send different HTTP requests for each item. I want so:

a. has anyone got a method of replacing more than one item in a HTML document using AJAX? e.g <p id="pid12345"></p> would be populated with <p id="pid12345">£1.50</p> when the ID pid12345 is found in the XML server response?

b. how can i request and repeat the process every 5 seconds?

View 19 Replies


ADVERTISEMENT

Ajax :: Multiple Selections To JS?

Apr 29, 2010

I'm sorry if this question has been answered before, but I'm a real noob trying to understand Ajax and JavaScript.

Therefore I need a (simple) explanation how to pass multiple selections from a list to my Ajax-script - if there are any simple solutions.

I'm not using any kind of framework - just plain Ajax/JS, PHP and of course HTML.

View 2 Replies View Related

AJAX Updating Multiple Div's

Mar 25, 2007

What's the easiest way to update multiple div's with AJAX? Right now I'm using the following code to update one div, but right after I've updated that div I would need to update another div that is dependent on the first div that is updated. Code:

View 2 Replies View Related

AJAX :: Pass Multiple Variables From PHP ?

Jul 8, 2010

I'm using AJAX to, on the click of a button, run a PHP script that dynamically generates a new line of text, and passes that to the script.The PHP script, new_sentence.php, just echos out the sentence.This works fine.But what I would like to do is for the PHP script to dynamically change JavaScript variables.how to pass multiple variables from PHP to JS.I can, of course, pass one by having the PHP script echo anything, and then use JS to set the variable to the PHP output. But what if I wanted to set two or three JavaScript variables at once?Here's my code in the HTML page that contacts new_sentence.php:

Code:
function ajaxRefresh(){
var ajaxRefresh;
ajaxRequest = new XMLHttpRequest();[code].....

When I press the "Refresh" button on the HTML page, it runs the ajaxRefresh function, which calls new_sentence.php. Then, once it gets the response, it changes the text of the element named "div" to whatever text the new_sentence.php echos.I'd like to figure out how to get a couple of variables.I would imagine this is simple. how to set the variables in PHP and then how to retrieve them in JS.

View 4 Replies View Related

Ajax :: How To Update Multiple DIVs Accordingly

Oct 18, 2009

I am creating a form. The form uses variable to show different divs. Like for example .
If the user chooses state where tax will be implemented than it will update the div which contain total amount. Now the problem is I have 3 divs on a page and I want to update all of them accordingly. Like user select quantity as 500, state as florida. So I need to update 3 divs .. total cost, Shipping cost and quantity divs. Problem is they all r not inside a single div else I would have put tht whole div inside the response. So is there a way to update multiple divs?

Below id the ajax code I am using ..
Code:
function update_dockcontent() {
var quantityval = document.HVAC_Cards_Form.Quantity.value;
var BillingZip = document.HVAC_Cards_Form.BillingZip.value;
var url = '[URL]'+quantityval+'&BillingZip='+BillingZip;
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
if (req.overrideMimeType) {
req.overrideMimeType('text/xml');
} .....

Code for ajaxcall page is:
Code:
<?
header("Cache-Control: no-cache");
header("Pragma: no-cache");
$total=($_GET[qval]*0.50);
$shippingrate="50";
if($_GET[BillingZip]) {
$total=$total+$shippingrate;
}?>
<p>Total Quantity: <strong><?=$_GET[qval]?></strong></p>
<p>Shipping: <strong><?=$shippingrate?></strong></p>
<p>Total cost: <strong>$<?=number_format($total,2)?></strong></p>
I want to show all 3 of them in different divs.

View 3 Replies View Related

Updating Multiple DIVs With Ajax?

May 10, 2011

I've created an ajax function which retrieves comments from a news article. But if I am logged in I will also have access to an input field for posting comments. The problem / question is that if I use Ajax I can only update one div with the responseText? How would I go about updating another one where I want to insert my form field. Can I make multiple requests in some certain manner or do I simply create another ajax function updating it separately?

http.onreadystatechange = function(){
if(http.readyState == 4){
document.getElementById(newsId).innerHTML = http.responseText;
}}
http.open("GET", "AjaxController.php?func=newsGetComments&showcomments="+newsId, true)
http.send();

View 3 Replies View Related

Ajax :: Handling Multiple Requests?

May 15, 2011

This might seem like a silly question..First issue. If i have a response and i'd like to update both text div and a status div how would i go about doing this. I've seen that jQuery has a few options such as OnSuccess etc?

Say that i post a comment and obviously you'd want to update some kinda statusbar on your website with the info that the message was posted successfully with ajax. (otherwise it might slip by the user unnoticed since ajax is kinda discrete)

Would it be a good way to for instance check the responseText if it contains anything and if it does you simply write a successmessage by grabbing a div from JS and if the responseText contains a custom error code lets say 1 you'll update the statusbar with a deny message?

Second thing. I've currently created an Ajax search on my site which activates whenever the user press or unleash the button. The issue is that if the user types fast enough it comes stuck showing the Loading.gif constantly. Could this be due so many requests opening and that i have a sleep on the server-side and if so how would you do it instead? I am using a serversleep of 1 second to have the Ajax pic appear consistently.

[Code]...

View 4 Replies View Related

AJAX :: Pass PHP Multiple Variables?

Oct 19, 2010

I've recently begun using AJAX on my website and have ran into a problem.My webpage: catalogue.php contains a category variable named $cid which the page GETS in order to display products from the correct category. This works fine.I now want to implement a drop-down box to sort by price, name, newest etc...I have tested the AJAX out with a dropdown box for changing the category and it works fine, this is because it is only passing one variable which it gets via the javascript "this.value".

The sort by price box requires two variables to be passed .I can pass the "this.value" which tells the javascript function I want to sort by price/newest/etc but I cannot figure out how to pass the category variable ($cid) so that when the xmlhttp.open calls the url: getSort.php it passes both pieces of info.My javascript is:

Code:
function showSort(str)
{
var cat = <?php echo $cid ?>;[code].....

View 5 Replies View Related

Ajax :: Sends Multiple Requests

Aug 19, 2011

I have a jsp page using ajax that has a button with an action. The action sends multiple ajax requests. The response from these requests is to be used to update a progress indicator to show the servers current progress. I can see from the debug that I am getting the 1st response. I think it is the way how I have implemented the further requests. I think this is down to my javascript knowledge, which isnt very much. Also I assume using multiple requests in this way is the correct thing to do? I have spent ages trawling the internet trying to get a solution.

View 4 Replies View Related

Ajax :: Multiple Get Element By Id Functions

Aug 31, 2010

I'm using an ajax function to call multiple php files to the same HTML web page. Dividends must be dynamic the data is stock prices. It seems that the last stock price is only updating the other 9 are not is their a limitation to the number of ajax functions used in a single web page. Here is the code I'm using 10 times is separate div's

[Code]..

View 2 Replies View Related

JQuery :: Ajax Dialog Box With Multiple Fields

Aug 31, 2009

I need a dialog box to appear when a person clicks the add to cart link on my site, where they are asked to fill in certain fields, and then click next, still inside this dialog and then move on to the next part to fill in more options, when done, must show in this dialog still, "thank you added to cart successfully". This all using php, ajax, jquery.

A good example of this, is for example: facebook >> add friend >> friend successfully added >> suggest this person to friends. Where a lot of stuff happens, but each time you click, action to php already been executed, even though the dialog is not yet closed. Basically everything that normally happens when you post, but only in a dialog.

View 1 Replies View Related

Updating Multiple Elements Using One Ajax Call?

Dec 1, 2009

How could I go about doing this?

View 9 Replies View Related

Ajax :: Possible To Get Multiple Variables From External File?

Jul 20, 2009

I have used AJAX lots before and I wondered if it was possible to set variables from an AJAX file E.g. an ajax file could set
var set1 = 10;
var set2 = 55;
with both variables coming from an external file called by AJAX. Which JS side perform the request and the format of the file that is requested.

View 4 Replies View Related

Ajax :: Passing Multiple Vaules In Post

Jun 22, 2010

function ShowAvailability() {

View 1 Replies View Related

JQuery :: Multiple Ajax Calls On One Page?

Jan 12, 2011

Basically, what I am trying to do is call several ajax requests using jQuery on the same page, i know that all browsers are capable of requesting multiple requests. However in Chrome and Safari my website works fine, but IE, Firefox and Opera all only call the first request then dont call, the second two. I dont know why though?

All of the code for the site is here: [URL]

View 5 Replies View Related

Ajax :: Post Multiple Data With (Jquery)?

Feb 7, 2011

I got this code that dealing with ajax..Basically the ajax code is to get the data from the html element and insert it to the database.

this is ajax and the html code ...

View 1 Replies View Related

Ajax :: Php Mysql Populate Multiple Textbox

Mar 2, 2011

[URL] Refer to the link, using the sample, I'm able to use php ajax to populate 1 text box which I've already pre-define (not using "echo '<input type='text'..") -- the info came from a table

e.g.
Search: [jo ]
Name: [John doe]
sql
---
select name from customer where name like '%jo%';
[Code]...

View 4 Replies View Related

Ajax :: Multiple Requests At Same Time Not Working

Apr 18, 2011

I'm encountering an AJAX problem when I try to execute multiple AJAX requests at the same time. What I want to do is delete a message and display the status (succes or failure) of that in div1, and refresh the messages on the page in div2. This needs (for as far as my knowledge reaches) two AJAX actions from which I both need the responseText.

The problem:
What happens when I execute my script is that the second action (refresh a part of the page) happens before the deletion is executed. The result of this is that when the deletion has been executed, the page is already updated, and the deleted message is still there.

The script
What I now have is:
function doAjax(url, element_id, img_url){
var ajaxObject = createAjaxObject();
ajaxObject.open('GET', url, true);
ajaxObject.onreadystatechange = function(){
if(ajaxObject.readyState==4 && ajaxObject.status==200){
document.getElementById(element_id).innerHTML = ajaxObject.responseText;
delete ajaxObject; .....

View 3 Replies View Related

Ajax :: Sending Multiple Requests To Server

Mar 18, 2009

I need to send 15 requests to my server and get results, these results are queries to other sites. I then update my page with the results. I need to know if I am taking the correct approach, as things are working a bit slow, and i.e., seems the be as slow as a snail.

Here is my function for the first request
Code:
function one(){
var xmlHttpa=null;
try{
xmlHttpa=new XMLHttpRequest();
} catch (e){
try {
xmlHttpa=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e){
try {
xmlHttpa=new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("Your browser does not support AJAX!");
return false;
}}}

xmlHttpa.onreadystatechange=function(){
if(xmlHttpa.readyState==4){
document.getElementById('resulta').innerHTML = xmlHttpa.responseText;
var el = document.getElementById('showMessagea');
el.parentNode.removeChild(el);
applystyle();
}}
xmlHttpa.open("GET","one.php",true);
xmlHttpa.send(null);
}

I then call this function and others from my page, one(); two(); etc. Am I correct in my approach?

View 1 Replies View Related

AJAX :: Call Multiple Functions On Onload?

Jan 28, 2010

how to load multiple functions on window.onload and these functions could be in a seperate ajax file.

<html>
<head>
<script type="text/javascript">
window.onload(func1);

[Code]....

func1 and func2 are in a seprate ajax file. In this case only func2 works and func1 is not works.

View 2 Replies View Related

AJAX :: Retrieve Multiple Values From Php File Using It?

May 12, 2009

How would i retrieve multiple (GET) values from a php file using AJAX..

Say i had the following function that ask's for a userID variable - how could i ask for more than one variable instead of just userID? [code]...

View 4 Replies View Related

AJAX :: PHP Multiple Dropdown - Populating From The Menu

May 25, 2009

The second menu is populating correctly from the first menu. The third menu doesn't work because it is not pulling the cat1 & cat2 values. I suspect it is the "checkNew" function, which I tried (with limited Javascript knowledge) to copy and alter from the "checkSelected" function.

[Code]....

View 4 Replies View Related

Ajax :: Calling Multiple Functions With OnChange?

Feb 25, 2009

I have a series of dropdowns that allow the user to choose country, province and town respectively. The province dropdown is populated by an Ajax function when the user chooses their country, and the town dropdown is likewise populated by the user's selection in the province dropdown. This all works fine.

Of course, my client now wants to add a "major centres" dropdown between the province and town selection. This seemed straightforward to me, however in practice it's proving problematic. The "major centres" are drawn from the same dataset as the towns, however an extra flag is applied so that only records flagged as "main centre" appear.

Called separately , both the town dropdown and the main centre dropdown are populated. However, the problem comes in when the onChange event which is meant to update both dropdowns simultaneously fires. Watching the network behavior in Firefox, I see that calls to the ASP files which populate the town and major centre dropdowns DO happen, though only one of the calls actually returns values. I've checked this in IE7 also, and the same thing happens.

My function is called from the Province dropdown, like so:

Code:
<select name="Province" id="Province" onChange="callOthers(this);">
<option value="">---</option>
</select>

[Code]....

what might cause only the one dataset to be returned via Ajax? Either the towns are populated or the major centres, depending on which order I call the two handleOnChange functions from my callOthers function. As I said, BOTH Ajax calls are made, however only the results of ONE are being used in my page. Could this problem be related to 2 Ajax calls being made too close together?

View 2 Replies View Related

Can An AJAX Request Be Left Open For Multiple Responses?

Apr 14, 2006

Is it possible for an AJAX request to be left open for multiple responses? This could avoid repetitive polling of the server.

View 17 Replies View Related

JQuery :: Ajax Load Multiple Pieces Of Html?

Aug 19, 2010

So I know that with .load I can load a specific chunk of html. What if I want to load 2 chunks of html in one request? For instance my current page has

#nav and #content. My loaded page has the same and I want to replace these 2 elements with the new one (or it contents).

$('#nav').load(loadUrl + " #nav");
$('#content').load(loadUrl + " #content");

So the above doesn't work for me for 2 reasons: 1. I load twice. I don't want to do that (but I also don't want to load the js and all because it will mess things up) 2. This puts #content inside #content

View 2 Replies View Related

JQuery :: Ajax Plugin - Multiple Select Dropdowns

Apr 23, 2010

I'm looking for a jQuery AJAX plugin that allows me to do the following. I have three dropdowns ( Make, Model, Year), the values of the second and third dropdowns need to dynamically changed based on the selection of the previous dropdown.
Example:
Dropdown 1
Dropdown 2 ( would change depending on selection in dropdown 1 )
Dropdown 3 ( would change depending on selection in dropdown 2 )
Is there an existing plugin that works?

View 1 Replies View Related







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