XF 2.0 Need some help with AJAX...

Jaxel

Well-known member
I hate JavaScript.

I've got my template here (links cut out to save space)
Code:
<div data-xf-init="atendo-rsvpmenu" data-occur="{$occur->occur_id}" data-state="{$rsvp->rsvp_state}">

    <a href="{{ link(...) }}" class="menu-linkRow" data-state="y">{{ phrase('EWRatendo_going') }}</a>
    <a href="{{ link(...) }}" class="menu-linkRow" data-state="m">{{ phrase('EWRatendo_interested') }}</a>
    <a href="{{ link(...) }}" class="menu-linkRow" data-state="n">{{ phrase('EWRatendo_not_going') }}</a>
   
</div>


That hooks into my JavaScript:
Code:
EWRatendo.rsvpmenu = XF.Element.newHandler(
{
    state: null,
   
    init: function()
    {
        state = this.$target.data('state');
        this.$target.on('click', '.menu-linkRow', $.proxy(this, 'click'));
    },
   
    click: function(e)
    {
        e.preventDefault();
       
        if (state != $(e.currentTarget).data('state'))
        {
       
        }
    },
});


I need to execute the link in the "if" statement in my JS. I then need to run some more scripts on success; and do not reload the page.

Where do I get started?

Technically, I guess this link should POST.
 
Last edited:
Figured it out:
Code:
XF.ajax('POST', $(e.currentTarget).attr('href'), {}, function (data)
{
    this is on success?
}

I dont know how to send data to the JS in my PHP though.
 
Top Bottom