Solved

xajax not using variable

Posted on 2009-04-09
5
277 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
ID: 24109764
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
ID: 31568650
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
ID: 24112256
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
ID: 24112333
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
ID: 24112421
not working see new post please..
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

911 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

24 Experts available now in Live!

Get 1:1 Help Now