Skip to content

Instantly share code, notes, and snippets.

/**
*
* @param unknown_type $form
* @param unknown_type $form_state
* @return multitype:string NULL
*/
function multifiles_example_form($form, &$form_state) {
$form['#tree'] = TRUE;
/**
*
* @param unknown_type $form
* @param unknown_type $form_state
* @return multitype:string NULL
*/
function multifiles_example_form($form, &$form_state) {
$form['#tree'] = TRUE;
@RimonEkjon
RimonEkjon / jquery.ajaxSubmit.js
Created August 26, 2014 04:25 — forked from mollwe/jquery.ajaxSubmit.js
Gets all input values within form and submits form with ajax.
/*!
* jquery.ajaxSubmit.js - v 0.9.3 (2011-11-29)
* Copyright (C) 2011 by Adam Ydenius ([email protected]) | http://mollwe.se
* Dual licensed under MIT and GPL.
*//*
* Gets all input (with name attribute) values within form and submits form with ajax.
* First argument, options, is object with:
* Properties:
* - url: override form action.
* - method: override form method.
{{ Form::open(['data-remote', 'data-remote-success-message' => 'I have now done the thing.']) }}
{{ Form::text('name') }}
{{ Form::submit('Submit', ['data-confirm' => 'Are you sure?']) }}
{{ Form::close() }}
<?php
/**
* @var array $scriptProperties
* @var AjaxForm $AjaxForm
*/
$AjaxForm = $modx->getService('ajaxform', 'AjaxForm', $modx->getOption('ajaxform_core_path', null, $modx->getOption('core_path') . 'components/ajaxform/') . 'model/ajaxform/', $scriptProperties);
if (!($AjaxForm instanceof AjaxForm)) {
return '';
}
$AjaxForm->initialize($modx->context->key);
@RimonEkjon
RimonEkjon / Ajax - Jsonp - script.js
Created August 26, 2014 04:16 — forked from bencooling/script.js
jsonp workflow
$(function(){
var xhr, $form = $('form');
function getResponse(data){
console.log(data);
}
function postForm(){
return $.ajax({
'dataType' : "jsonp",
// create a new dbStore stack
var myStack = localStack('myLocalStack');
function onFormSubmit(){
// push form data into local storage
myStack.push( $('form').serializeArray() );
// see if we can send data to the server
checkForConnection();
}
$('#thing form').submit(function(e) {
var $this = $(this);
e.preventDefault();
$.ajax({
type: this.method,
dataType: "JSON",
url: this.action,
data: $this.serialize(),
success: function() {
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var form = $('#form'); // contact form
// form submit event
function AjaxForm() {
$("form.ajaxform").submit(
function(e) {
e.preventDefault();
var dataString = $(this).serialize();
var method = this.method.toUpperCase();
var action = this.action;
$.ajax({
type: method,
url: action,