-1

How do I make an AJAX call or submit form in ATG. Here's the code I'm using:

document.getElementById("myP").style.visibility = "hidden";

Will this work in the sense of ATG?

Akeshwar Jha
  • 4,516
  • 8
  • 52
  • 91
pradeep murugan
  • 531
  • 1
  • 9
  • 18
  • 2
    Changing the visibility of an element using javascript has absolutely no bearing on making an AJAX submit in ATG. What are you trying to do specifically? – radimpe Jan 04 '16 at 18:54

1 Answers1

0

For ajax calls, in applications like spring and standard J2EE, you do a GET or POST call using AJAX for the form's action URL.

In ATG, you dont have action URLs. Rather, you have bean references, somewhat like

<dsp:form id="myForm">
   <dsp:input type="myField1" bean="ABCFormHandler.myField1" />
   <dsp:input type="myField2" bean="ABCFormHandler.myField2" />
   <dsp:input type="submit" bean="ABCFormHandler.myProcess"  style="display:none"/>
   <dsp:input type="button" id="formSubmitter" value="Submit"/>
</dsp:form>

Here, we have defined a method called handleMyProcess in the ABCFormHandler, which also contains the properties myField1 and myField2.

  1. Notice that the form tag has the id "myForm".

  2. Next, there are two fields viz. "myField1" and "myField2".

  3. There is a submit button which is hidden, by setting the style to "display:none"

  4. Lastly, we have a normal button, for which we have simply set an id called "formSubmitter".

Now, we will use this normal button to submit the form with id "myForm".
We just need to call the form's submit() method using jQuery, which can be done simply as:

$('#formSubmitter').on('click', function(){
     $form = $('#myForm');
     $form.submit();
});

Hope this helps!

Monis
  • 918
  • 7
  • 17