Link to home
Start Free TrialLog in
Avatar of ALASKASTREETMASTER
ALASKASTREETMASTERFlag for United States of America

asked on

xajax not using variable

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

ASKER CERTIFIED SOLUTION
Avatar of Roger Baklund
Roger Baklund
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ALASKASTREETMASTER

ASKER

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.
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.
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');");
not working see new post please..