0

I am using the Zend Framework 2 and would like to pass a variable from my action to javascript.

Controller Code:

fooAction
{
return 'bar'
}

JavaScript Code

$.post('foo', { week: week, day: day, time: time }, function(data) { $(id).html(data); });

I would like to pass the value 'bar' back to javascript. Currently if I do something like the below I get the correct results. I would like to use a variable from the action instead of hard keying it.

$.post('foo', { week: week, day: day, time: time }, function(data) { $(id).html('bar'); });

Many Thanks, Matt

Matt
  • 383
  • 1
  • 5
  • 20
  • `How do I pass variable from PHP to Javascript` Woo can't even count anymore how many times this was asked before! – Rizier123 Jan 07 '15 at 22:41
  • You don't pass it, you print it. `echo` it in the PHP being called by the ajax and it shows up in the `data` variable. – developerwjk Jan 07 '15 at 22:42

0 Answers0