2009年12月15日星期二

[fw-mvc] Odd ZF MVC behavior when using Ajax

Hi all, I am new to the list here, subscribed last night. Although, for some
reason nabble is still flashing a "subscribe to this mailing list" message.

Anyway, I come to you because I need to know if I am trying to do something
that is not possible. Let me explain:

I am working on a youth group social network site. A few pages call a
dynamic widget from their view file. The widget I am calling is a post
form/tool, similar to the one found on facebook. The pages using the post
form widget include a news page, a devotion page, and (soon) a posts page. I
call it like this:

<?=$this->action('postform','content','content',array('type' =>
'devotion','targetGroupId' => $this->groupId))?>

In keeping with the modular nature of the ZF MVC, I created the news and
devotion pages as stand alone. Now, when requested "normally" the above code
works great. However, I wanted to improve the user experience by loading the
news and devotion pages from a single group home page. Oddly, when
requesting the news and devotion pages using ajax, the above code does not
execute. The pages do load though, and my Firebug console shows me that I am
receiving no content from the postform action. The content from the news and
devotion pages load as expected. Also, my first thought was that I was
somehow losing track of the session using the ajax request, but I quickly
proved that to not be the case. Here are my attempts to initially load the
news page from the group page:

$(document).ready(function(){
//$('#group-content-panel').load('/content/news/view/groupId/<?=$group['id']?>');
$.post(
'/content/devotion/view/groupId/<?=$group['id']?>',
{},
function(content){
$('#group-content-panel').append(content);
},
'HTML'
);

I am using jQuery here. I tried using both the GET load() function and the
post() function. The response is the same. I suspect that this has something
to do with how the Zend MVC handles requests. In that case, I need help :)
If someone can tell me why this is not working, or if it can even work at
all, that would be awesome.

Best regards to you all...

--
View this message in context: http://n4.nabble.com/Odd-ZF-MVC-behavior-when-using-Ajax-tp964748p964748.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: