<p>Fixed it, it was just a matter of proper capitalization</p>

<pre><code>var url = Craft.getActionUrl('baseinstagram/main/testy');
</code></pre>

<p>Should have been </p>

<pre><code>var url = Craft.getActionUrl('Baseinstagram/Main/Testy');
</code></pre>

CC BY-SA 3.0
2016-12-22T10:17:30.147Z
2016-12-22T10:17:30.147Z
Antonin_artaud
<p>So, I've created a plugin which has to send dynamic data to an entry in the control panel, using a custom field type</p>

<p>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</p>

<p>This is what I have so far</p>

<p><strong>The custom field</strong></p>

<pre><code>public function getInputHtml($name, $value)
{

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

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

<p><strong>The ajax call</strong></p>

<pre><code>$(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');
        }
    });
});
</code></pre>

<p>});</p>

<p><strong>the controller</strong></p>

<pre><code>public function actionTesty() {
    $this-&gt;requireAjaxRequest();

    $this-&gt;returnJson('heyeyeye');

}
</code></pre>

<plugin-development>
Loading data in Ajax in an entry
# Loading data in Ajax in an entry

(Asked by: username_0 on 2016-12-22)

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');

}

**Tags:** plugin-development

---

## 1 answers

### Answer by username_0 on 2016-12-22. Score: 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');


---

