Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 3rd, 2010, 02: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() {
RequestManager.submit({
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
Reply With Quote
  #2 (permalink)  
Old May 9th, 2010, 01:01 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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)
http://www.nczonline.net/
Reply With Quote
  #3 (permalink)  
Old August 30th, 2012, 03:28 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2012
Location: Texas
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.

Code:
  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>".
                 $aValues['Nam_City']."<td><td>".$aValues['Nam_StateCode']."<td><td>".
                 $aValues['Nam_Zip']."<td><td>".$aValues['Nam_R_Phone']."<td><td>";
			"</table>";
	        } 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
Thanks

Last edited by Lonestarjack; August 30th, 2012 at 05:16 PM. Reason: My error
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 12:02 PM
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 01:02 PM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 10:40 PM



All times are GMT -4. The time now is 04:19 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.