Wrox Programmer Forums
BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6
This is the forum to discuss the Wrox book Professional Ajax, 2nd Edition by Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett; ISBN: 9780470109496
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 3rd, 2010, 01:59 PM
Registered User
Join Date: May 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default chapter 5 help

at chapter 5 i'm trying to use request manager but i have a problem,
this is my submit function:

function addSubmit() {
type : "post",
url : "queue.php",
data : "name=Nicholas",
onsuccess : outputSuccessResult,
onfailure : outputFailureResult,
onnotmodified : outputNotModifiedResult

i have modified output result to get data from php file

function outputResult(oResponse, sColor) {
var divResponses = document.getElementById("divResponses");
var oRequest = oResponse.request;
var sMessage = "<div style=\"background-color:" + sColor + "\">"
+ oResponse.status + " (" + oRequest.priority + ") "
+ oRequest.type + " " + oRequest.url + " " + oRequest.age + " " + oRequest.data + " " + oResponse.data + "</div>";
divResponses.innerHTML += sMessage;

the post is done to queue.php if i have this:
$a = 'hi';
echo $a;

no problem at function outputResult
oRequest.data outputs 'hi' on browser

but if at queue.php i have this:
$a = $_POST[“name”];
echo $a;
function outputResult
oRequest.data outputs nothing on browser
i cannot get post value,
i dont have experience with js and ajax
could someone tell me how to get and output on screen the post value from
queue.php file

thanks a lot
Old May 9th, 2010, 12:01 AM
nzakas's Avatar
Wrox Author
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts

It's a bit difficult to tell what could be wrong from your description, but you should double-check that $_POST is available and readable first. Although $_POST is usually available, it might not always be. See http://www.php.net/manual/en/languag...perglobals.php

You may also want to try sending other data to queue.php to see if it gets through, or try using a GET instead of a POST to rule out general data transmission issues.
Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
Old August 30th, 2012, 02:28 PM
Registered User
Join Date: Aug 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Formatted table return

No problem -- I forgot the "<tr>" function. Dumb me.

What is the secret in having AJAX return a formatted table?
I plan on displaying a series of detail records.

  if ($sInfo == "") {
        if($oResult = mysql_query($sQuery) and mysql_num_rows($oResult) > 0) {
		$aValues = mysql_fetch_array($oResult,MYSQL_ASSOC);
		echo '<table border = "2">	';	
		echo '<th>Name</th></th>Address<th>City</th><th>State</th><th>ZIP</th><th>Phone</th></ p>';
		$sInfo = "<td>".$aValues['Nam_Last']."</td><td>".$aValues['Nam_Street']."<td><td>".
	        } else {
           		 $sInfo = "Customer with ID $sID doesn't exist.";
Returns with a border and heading plus detail, but not formatted as atable
Name Address City State ZIP Phone Catran 5240 Bothwell Rd Tarzana CA 91356

Last edited by Lonestarjack; August 30th, 2012 at 04:16 PM.. Reason: My error

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 6 - Code Download Missing for this Chapter dbaechtel BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 August 11th, 2009 11:02 AM
Chapter 2 - End of chapter exercises whizzkid1892 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 30th, 2008 12:02 PM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.