0

I am writing a script using AJAX in JQuery that takes an action_id from exp_actions as the destination URL for the method I need to execute in my mcp file. The reference is made statically. Can the ACT value be found by making a PHP call in the view in a way similar to:

$aid =$this->EE->cp->fetch_action_id('Class_name', 'method_name'); ?

My page currently looks this way:

<script type= "text/javascript">
$(document).ready(function() {
    $('form').change(function(e){
        var data = $(this).serializeArray();
        console.log(data);
        $.post(
            <? echo'http://ourwebsite.com/ee/admin.php?ACT=44&id=4 ,';?>
            data,
            function() {
                console.log(this);
            } 
        )
    });
});

Thanks in advance!

JordWms
  • 13
  • 3

3 Answers3

1

So I found the answer to my question on the expressionengine forums. For those curious, the link is below. Thanks for the help :)

http://expressionengine.com/forums/viewthread/171401/#986831

JordWms
  • 13
  • 3
  • Welcome to Stack Overflow! While this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Bill the Lizard Apr 24 '12 at 18:02
0

Assuming you are using that script in a template or a snippet, you could make a call to your addon instead, returning the needed URL:

<script type= "text/javascript">
$(document).ready(function() {
    $('form').change(function(e){
        var data = $(this).serializeArray();
        console.log(data);
        $.post(
            '{exp:your_addon:method_for_getting_action_id_url}',
            data,
            function() {
                console.log(this);
            } 
        )
    });
});
Repox
  • 15,015
  • 8
  • 54
  • 79
  • For the purposes of my page, I am hoping to do this from the view file of this module or within the mcp file. Is this possible? – JordWms Apr 23 '12 at 20:52
  • Sure, why not just pass the info as dato to the view you are returning? – Repox Apr 23 '12 at 21:18
0

If you want to make an ajax request in the CP, you just need to request the cp url:

/system/index.php?S=0&D=cp&C=addons_modules&M=show_module_cp&module=my_module&method=my_method
pvledoux
  • 973
  • 1
  • 10
  • 23