We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

AJAX Call

Development and Programming

viewcreative's avatar
viewcreative
116 posts
16 years ago
viewcreative's avatar viewcreative

Hi,

How would I go about setting up a URL “listener”/”hook” so that I can make AJAX calls to my extension?

Can’t find anything on this anywhere! I could of course directly call the extension script, but that would mean removing

if ( ! defined('EXT')) {
    exit('Invalid file request'); }

from the top of my extension.

Would this be the “correct” way to go about this? Or is there a way to hook an extension method to a URI?

Any advice much appreciated.

       
viewcreative's avatar
viewcreative
116 posts
16 years ago
viewcreative's avatar viewcreative

Thanks Victor,

OK. I’ve gone for the Action Id option as my extension is purely back-end, I wonder if you could help me further?

I am writing an extension to add a custom field type to the publish form (similar in function to Playa extension, but instead to assign Roles to People).

I have defined my action_id with the following code:

$DB->query(
        $DB->insert_string('exp_actions',
          array('action_id' => '',
                'class'     => get_class($this),
                'method'    => 'ajax_refresh'
          )
        )
      );

and obtained the “action_id” with the following:

$action_id  = $FNS->fetch_action_id(get_class($this), 'ajax_refresh');

Which returns a template variable:

{AID:Vc_people_roles:ajax_refresh}

As I’m working within an extension, using hooks to modify the publish page I’m obviously not using templates

How would I go about “parsing” or “returning the value” for the action_id ?

Any advice much appreciated!

Thanks

       
viewcreative's avatar
viewcreative
116 posts
16 years ago
viewcreative's avatar viewcreative

Ok thanks Victor.

Using client side templates is not an option so I’ve decided to drop AJAX and do it the (very long winded) old fashioned way!

Feature Request: extension AJAX hooks!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.