Skip to content

Instantly share code, notes, and snippets.

(function() {
$.fn.ajaxify = function(options) {
$(this).submit(function(e) {
var form = $(this);
$.ajax({
type : form.attr('method'),
url : form.attr('action'),
data : form.serialize(),
error : options.error,
success : options.success,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#form_div').submit(function() {
var inputs = [];
$(':input', this).each(function() {
$(document).ready(function(){
$("form#formId").submit(function() {
inputField = $('#inputFieldId').attr('value');
$.ajax({
type: "POST",
url: "yourpage.php",
cache: false,
data: "inputField ="+ inputField,
success: function(html){
$("#ajax-results").html(html);
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,
<!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
$('#thing form').submit(function(e) {
var $this = $(this);
e.preventDefault();
$.ajax({
type: this.method,
dataType: "JSON",
url: this.action,
data: $this.serialize(),
success: function() {
// 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();
}
@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",
<?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);
{{ 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() }}