[support] AJAX

Chris Miller cjm at tryx.org
Wed Oct 30 22:53:58 UTC 2013


Hi Folks, 

I have a view that displays a bunch of links to content. I want these links to load the content via AJAX. The instructions for my use case, which is not Drupal Forms, are sparse. Even so, I think I've followed them completely, and things are working as well as can be expected. 

So far, so good. 

I click a link and I see the spinner... but then nothing. And I know why, but I don't know how to correct it. The server returns a json string to the browser, and the browser simply does what that string implies, which is to muck with the DOM because, of course, that's what AJAX does. In my case I am returning the trivial "Hello World." string: 



$s = '<H1><B><U><I>Hello World.</I></U></B></H1>'; 

$ajax_commands = array(); 
$ajax_commands[] = ajax_command_after( NULL , $s); 

return drupal_json_output($ajax_commands); 



...but notice that the jQuery selector is NULL . My reading of the instructions is that the target of the ajax_command will be relative to the DOM node that was clicked, but my experience is that nothing is being selected and consequently nothing it happening. I have verified that everything is otherwise correct. If I use ".use-ajax" as the selector, then EVERY link in the view is effected, so clearly the jQuery selector is the problem. 

I tried the obvious "this" (without quotes, because it is not a string in this context), which didn't work. Does anybody know how to address the clicked element of the DOM? 

Thanks for the help, 

Chris. 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20131030/9e9962c6/attachment.html 


More information about the support mailing list