Score:0

Multiple ajax form not working on whole site

rs flag

I have multiple pages which contains multiple ajax forms. When I am working on a particular form, its ajax submission is working. But at that moment, if I go to second page form, ajax submission not working and the page gets reloaded.

But after clearing cache, if I work on second page form, its ajax submission working, but then first page ajax form submission not working.

How will I manage multiple ajax forms on multiple pages?

My ajax submission code looks like this:

$form['actions']['submit'] = array(
  '#type' => 'submit',
  '#value' => $this->t('Submit'),
  '#attributes' => array('class' => array('btn-red')),
  '#ajax' => [
    'callback' => '::submitCallBack',
    'progress' => array(
      'type' => 'throbber',
      'message' => 'Please wait...',
    ),
  ],
);
berliner avatar
bd flag
I think you need to show more of your code. Otherwise it's difficult to help you.
4uk4 avatar
cn flag
How do you switch to the second page, is this also Ajax?
Souvik Das avatar
rs flag
@4uk4 no, its a simple another node
4uk4 avatar
cn flag
OK, please add the code how you embed the form in the node.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.