QassimAjax.js is jQuery plugin, anyone can create an Ajax form & Ajax events! POST & GET, set PHP cookie using Ajax, and more events.

QassimAjax Plugin

Using QassimAjax.js plugin, anyone can create an Ajax form, POST or GET, and you can create Ajax events, for example create LIKE BUTTON or set PHP cookie using Ajax, and more events.

QassimAjax Live Demo

Check 4 live demo.

Download QassimAjax

Download QassimAjax plugin with 4 examples from Our Server.

Installation

Include jQuery before QassimAjax.js plugin:

<script type="text/javascript" src="jquery-1.12.1.min.js"></script>
<script type="text/javascript" src="QassimAjax.js"></script>

Usage

Just call function with form, for example:

<script type="text/javascript">
    jQuery(function(){
        jQuery("#my-form").QassimAjax();
    });
</script>

<form id="my-form" method="post" action="my-action.php">
    <input name="bla" type="text" value="">
    <input type="submit" value="submit">
</form>

Options

resultWrap: 0, // This option to display result in HTML element using CSS selector, for example "#my-wrap", defalut is 0, if value is 0 will be display the result in alert message
fadeEffect: 1, // If "resultWrap" has CSS selector, will be display the result with fade effect, default is 1, 1 = enable, to disable it enter 0
setEvent: 0, // This option for event, for example if you want to create LIKE BUTTON, enter value 1, default is 0
eventTo: 0, // This option for event, for example to get likes count, enter CSS selector, default is 0
eventType: "GET", // This option for event, default event is GET, if you want POST, enter POST (upper case)
theMessage: 0, // This option for event and form, for example if value is 0, will be display the result in alert message, enter custom message, for example "Cookie has been added!"

Ajax Form Example

Form method “POST”, jQuery code:

jQuery(function(){
    jQuery("#post-form").QassimAjax( { resultWrap: "#post-form-result", fadeEffect: 1 } );
});

HTML code:

<form id="post-form" method="post" action="post.php">
    <input name="your-name" type="text" value="">
    <input type="submit" value="submit" id="submit">
</form>

PHP “post.php” file code:

<?php
    if( isset($_POST['your-name']) ){
        echo $_POST['your-name'];
    }
?>

Ajax Event Example

This is example to set PHP Cookie using Ajax, jQuery code:

jQuery(function(){
    jQuery("#get-event").QassimAjax( { setEvent: 1, eventType: "GET", eventTo: "#event-cookie" } );
});

HTML code:

<div id="event-cookie"></div>

<a id="get-event" href="set_cookie.php">Click Here</a>

PHP “set_cookie.php” file code:

<?php
    setcookie("background", "background", time() + 60); // 1 minute
    echo "Cookie has been added!";
?>

Enjoy.