2

I had this working an hour ago but must have changed something. How should I call a ajaxLink using ZendX so that any javascript in the response html get's executed? I tried with processData since I think I used that but now it doesn't work.

<?php echo $this->ajaxLink('Click me and I will run the returned javascript code',
                    $this->url(array('controller' => 'foo', 'action' => 'bar')),
                    array('id' => 'myid'),
                                'processData' => true,
                                'method' => 'post',
                                'async' => false
                    ),
                    array('a_posted_id' => $the_posted_id));?>
inquam
  • 12,664
  • 15
  • 61
  • 101

2 Answers2

0

How is the response being returned?

In general in the non-zend. You can build a javascript tag via javascript .

  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.text = "the returned javascript";
  document.getElementsByTagName('head')[0].appendChild(script);

This will automatically run the code.

Or have your Ajax return a url to a file and instead of text set the src of the tag.

 var script = document.createElement('script');
  script.type = 'text/javascript';
  script.src = "/the/returned/link.js"
  document.getElementsByTagName('head')[0].appendChild(script);

In both cases the javascript will be run automatically.

Sorry if this doesn't help.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Bodman
  • 7,938
  • 3
  • 29
  • 34
0

This SHOULD work and is probably just a bug somewhere in the ajaxLink() code. I ended up returning JSON encoded data and having javascript functions to act on the returned data instead.

inquam
  • 12,664
  • 15
  • 61
  • 101