Solved

xajax not using variable

Posted on 2009-04-09
5
278 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
age from date of birth 4 42
Javascript_Set_dropdown_value 7 33
Passport Expiry 3 44
Most efficient JavaScript way to verify if variable matches any value in the list? 6 23
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
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 …

810 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