This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » Developer » Ajax load of a form (content/action)

Ajax load of a form (content/action)

Ajax load of a form (content/action)

Thursday 22 July 2010 7:14:22 pm - 5 replies


I need to load the form to post comments on eZPublish articles : to do that, i'm using jquery framework. I'm always getting 404 errors when calling content/action with Ajax.

I'm using an empty layout, and try to load the form by making a POST query : something like this :

function loadAjaxContent(_url,_el,_params,_method)
        var params = (_params==null)? {} : _params;
        var method = (_method==null)? 'post' : _method;
           type: method,
           url: _url,
           data: params,
           dataType: "html",
           cache: false,
           success: function(response){
            error:function (xhr, ajaxOptions, thrownError){
                $('#'+_el).html("<p>Erreur lors du chargement : "+xhr.status+"</p>");

In the tpl file :

function newComment()
      var _params = 
             ContentLanguageCode:"{ezini( 'RegionalSettings', 'ContentObjectLocale', 'site.ini')}"
      return false;

I'm simply passing the expected parameters to generate the template , note :

  • I do not get errors when i try to display my form with empty layout in navigator,
  • Ajax function is working : i can display some other parts that do not need to be compute by action view.

Am I missing something ?

P-S : Maybe it has an importance, this website is running ez4.0

Modified on Thursday 22 July 2010 7:15:51 pm by Stéphane Le Merre

Thursday 22 July 2010 11:53:49 pm

What about using firebug to debug the xhr request? It will tell you if the url that you're posting to is correct, as well as the request's payload.

In the example you posted I think you might be missing some parameters to post to content/action.

Friday 23 July 2010 10:05:25 am

I think the problem could be in a fact that if you want to publish some content you need to have a draft already created.

Do you create a draft version of the object prior to publish?

Friday 23 July 2010 3:57:41 pm

Thanks for answering. I found out how to solve this by watching kernel/content/action.php, eZ uses the submit button name to control :

if ( $http->hasPostVariable( 'NewButton' ))

So we must had a post param call NewButton in my case :

function newComment()
    var _params = 
            ContentLanguageCode:"{ezini( 'RegionalSettings', 'ContentObjectLocale', 'site.ini')}",
    return false;

And it worked.

Thanks Gaetano happy.gif Emoticon

Modified on Friday 23 July 2010 3:58:18 pm by Stéphane Le Merre

Monday 25 April 2011 10:37:50 am

Sounds interesting...

I'd love to see the complete solution for this!

Monday 10 November 2014 12:21:27 am

can you help me? I've your same problem with a feedback form,

the AJAX call return me a 401 error


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from