SoFunction
Updated on 2025-04-13

Interaction between javascript form field and json data page 3/3


/*
* jQuery Ajax By Name Plugin
*
* licensed under the MIT licenses:
* /licenses/
*
* Author achun ( at )
* Create Date: 2008-6-21
* Last Date: 2008-6-21
* Revision:2.8.6.21
*/
(function($) {
/**
* Get the coordinates of the element of the mouse click
*/
$. = function(e){
var pos ={x:0,y:0};
if ( != undefined) {
= ;
= ;
} else if (typeof $. == 'function') {
var offset = ();
= - ;
= - ;
} else {
= - this[0].offsetLeft;
= - this[0].offsetTop;
}
return pos;
}
/**
* ajaxName() submits data according to the tag name attribute, instead of form submission method
* options:{//The same structure as ajax's options
* data:{}//The data to be submitted is attached
* }
* successful: if the element has a valid value, default:true
*/
$. = function(options,successful) {
if(options==undefined) options={};
= || {};
successful = successful == undefined ? true:successful;
var data = {};
var name= || '';
(function() {
var el=this,o=$(this),n = ('name'),hasval = ('value')!=undefined;
if (!n) return;
var t = , tag = ();
if (n=='/'){
if (name=='') name = hasval?('value'):();
return;
}
if (successful && ( || t == 'reset' || t == 'button' ||
(t == 'checkbox' || t == 'radio') && ! ||
(t == 'submit' || t == 'image') ||
tag == 'select' && == -1))
return;
var v= hasval? ('value') :('ValueByText')?():();
if (v == undefined) return;
if (('.')>0){
n=('.');
var len= - 1;
var b=data;
$.each(n,function(i){
if (i!=len){
if(b[this] == undefined) b[this]={};
b=b[this];
}else
b[this]=v;
});
}else if (('[]')>0){
n=(0,-2);
if(data[n] == undefined) data[n]=[];
data[n].push(v);
}else{
data[n]=v;
}
});
var dat={};
if (name){
dat[name]=data;
data=dat[name];
}else
dat=data;
for (var o in ){
data[o]=[o];
};
=dat;
return ;
};
})(jQuery);