Solved

xajax not using variable

Posted on 2009-04-09
5
276 Views
Last Modified: 2013-12-13
Hi,,
I have something wierd going on with xajax.  In the code below, the variables in the $myhtml variable all show up in the response script alert('$myhtml') when sent to the javascript so I know all the values are being retrieved from my query.  The thing i dont undestand is that the only two variables that can be added to the script are $row and $taxid. If I add any of the other variables such as sub = $sub; the response does not get back and nothing happens. I take them out and it works. I tried a second response object and it does not work with any other variables either whether i use either or both of the response objects.  As long as the response object is exactly $objResponse->script("row=$row;taxid = $taxid;alert('$myhtml');"); it works. I need to transfer more than just the two variables. Is there a limit in the response?

Any ideas?

Thanks
$myhtml = " Count: ". $row . " Taxid: ". $taxid . " Legal: " . $sub . " " . $blk . " " . $lot . " Owner: ".$fname . " " . $lname;

$objResponse = new xajaxResponse();

$objResponse->script("row=$row;taxid = $taxid;alert('$myhtml');");

$objResponse->script("sub = $sub;blk = $blk;alert('$myhtml');");
 

return $objResponse;

Open in new window

0
Comment
Question by:ALASKASTREETMASTER
  • 3
  • 2
5 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 500 total points
Comment Utility
No, there is no limit. $row and $taxid are both numeric, are the other values numeric or strings? If they are strings, they must be within apostrophes in the javascript:

$objResponse->script("sub = '$sub';blk = '$blk';alert('$myhtml');");
0
 

Author Closing Comment

by:ALASKASTREETMASTER
Comment Utility
Thanks, that worked.  The taxid is a number, but actually a text field in the server. It did not dawn on me to use the apostrophes i thought they were all retrieved the same way since taxid was a text field and $row was a numer.
0
 

Author Comment

by:ALASKASTREETMASTER
Comment Utility
How would you encode this variable to include line breaks? I have tried <br>, \n, \r\n.

$myhtml = " Count: ". $row . " Taxid: ". $taxid . "\r\n Legal: " . $sub . " " . $blk . " " . $lot . " \r\nOwner: ".$fname . " " . $lname;

$objResponse->script("alert(myhtml = '$myhtml';")

Thanks.
0
 
LVL 39

Expert Comment

by:Roger Baklund
Comment Utility
You must double the backslashes, because they are consumed first by PHP, then by javascript in the browser.

$myhtml = " Count: ". $row . " Taxid: ". $taxid . "\\r\\n Legal: " . $sub . " " . $blk . " " . $lot . " \\r\\nOwner: ".$fname . " " . $lname;
$objResponse->script("alert('$myhtml');");
0
 

Author Comment

by:ALASKASTREETMASTER
Comment Utility
not working see new post please..
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now