1

So, I've created a plugin which has to send dynamic data to an entry in the control panel, using a custom field type

I get an error in the ajax call, saying that the URL to which I'm posting is not found. I've debugged this and the URL generated is the right one, I've tried posting to it from other places and it works just fine

This is what I have so far

The custom field

public function getInputHtml($name, $value)
{

    craft()->templates->includeJsResource('baseinstagram/js/pullajax.js');

    return craft()->templates->render('baseinstagram/input/choosetag', array(
        'name'  => $name,
        'value' => $value
    ));
}

The ajax call

$(document).ready(function () {

var url = Craft.getActionUrl('baseinstagram/main/testy');

$('.pullme').click(function () {
    $.ajax({
        method : 'POST',
        url : url,
        success : function () {
            console.log('ok');
        },
        error : function() {
            console.log('nope');
        }
    });
});

});

the controller

public function actionTesty() {
    $this->requireAjaxRequest();

    $this->returnJson('heyeyeye');

}
2

Fixed it, it was just a matter of proper capitalization

var url = Craft.getActionUrl('baseinstagram/main/testy');

Should have been

var url = Craft.getActionUrl('Baseinstagram/Main/Testy');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.