Jump to content
Sign in to follow this  
Sim

Buttons unregonized with ajax

Recommended Posts

So the forms with buttons seem to go unregonized by the modules.

<button type="submit" name="submit" value="true" class="btn">Update</button>

   

The Ajax:

  jq("#php__container").on('submit', 'form', function(e){
      e.preventDefault();
      alert(jq(this).serialize()); 
      var url = jq(this).attr("action");
    
      jq.ajax({
        type: "POST",
        url: url,
        data: jq(this).serialize(), 
        success: function(data)
        {
          alert(data);
          jq("#php__container").html(data);
           // show response from the php script.
        }
    });
    return false;
  });

$this->methodData->submit will always be empty. Every other fo element will have it's value. Anyone got any ideas on what's going on?

Share this post


Link to post
Share on other sites

Take a look at the documentation: https://api.jquery.com/serialize/

> Note: Only "successful controls" are serialized to the string. No submit button value is serialized since the form was not submitted using a button. For a form element's value to be included in the serialized string, the element must have a name attribute. Values from checkboxes and radio buttons (inputs of type "radio" or "checkbox") are included only if they are checked. Data from file select elements is not serialized.

Share this post


Link to post
Share on other sites

"since the form was not submitted using a button". The form does getting submitted using a button.

 

Now I get to pick on yo for giving me wrong URL:

Screenshot_20200629-180031.thumb.png.2915fd0860498dc625b1cc6d84453360.png

Edited by Sim

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...