modified: 2020-02-12T10:07:01+01:00

An important task of Ajax is the submission of forms. Validation of forms with PHP and return of error messages to the browser.


The js function is the same as in xajax. Jybrid searches all form elements internally and collects them into a sendable object.

What you need is a html form with an html-id

<form id="myForm">
    <label>My Form Element <input name="myInput"></label>

HTTP form method

The form method attribute in the form tag is ignored. So you have the decide before during the following expressions between GET and POST.

Ajax form submit with POST

$jybridCmsPost = \Jybrid\Factory::register('testing_post', ['method' => 'POST']);
$onclick = $jybridCmsPost->getButtonScript()->setGetFormValues('myForm');

Ajax form submit with POST in object-orientated style Request::gi()->setMethodPost()

$jybridCmsPost = \Jybrid\Factory::register('testing_post', Request::gi()->setMethodPost());
$onclick = $jybridCmsPost->getButtonScript()->setGetFormValues('myForm');

Ajax form submit with Get

$jybridCmsGet = \Jybrid\Factory::register('testing_will_get', ['method' => 'GET']);
$onclick = $jybridCmsGet->getButtonScript()->setGetFormValues('myForm');

Ajax form submit with Get in object-orientated style Request::gi()->setMethodGet()

$jybridCmsGet = \Jybrid\Factory::register('testing_will_get', Request::gi()->setMethodGet());
$onclick = $jybridCmsGet->getButtonScript()->setGetFormValues('myForm');

Ajax Submit button with the jybrid "button"

<a href="#0" onclick="<?php echo $jybridCmsPost->getButtonScript()->setGetFormValues('myForm') ?>">Submit Form</a>

write javascript directly (equivalent to the php/html expression above)

<a href="#0" onclick="jybrid.Exe('testing_post',jybrid.getFormValues('myForm'));">Submit Form</a>

Please note that in jybrid ajax-formular and the values are transferred differently than in xajax. in xajax POST-parameters in an array were xargs[]={"key": "formvalue"} are transmitted. With jybrid form variables are transferred as if they were transferred with a regular form. This is one reason why jybrid is suitable as an Ajax framework for content management systems.


@see simple schematic-ajax-form.php

further reading ajax examples

@see simple schematic schematic-form.php