Wednesday, July 3, 2013

jQuery.submit() - json.parse(String) - json.stringify(Object)

JSON.parse is the opposite of JSON.stringify

JSON.parse(String)


var str = '{"hello":"world"}';
var obj = JSON.parse(str);
console.log(obj.hello);  // world

JSON.stringify(Object)

var obj = ...;
var json = JSON.stringify(obj);  
var obj2 = JSON.parse(json);

Jquery Submit

1. //prepare a handle first
$('#formID').submit(function(event) {

//JQuery - getting submit data form

    var values = {};
    $.each($('#formID').serializeArray(), function(i, field) {
   values[field.name] = field.value;
   console.log(field.name+"\t"+values[field.name]);
    });
}

2. //subimit form
$('#formID').submit();

JQuery Validate Field Value

.val() will give you an input element's value.
if ($("#element").val() == "") alert ("Empty!");



Related Posts:

  • Top 10 Best TabletsTop 10 Best Tablets   Source: http://www.pcmag.com/article2/0,2817,2413145,00.asp … Read More
  • Top 10 Best Digital CamerasTop 10 Best Digital Cameras   Source: http://www.pcmag.com/article2/0,2817,2369450,00.asp … Read More
  • Top 10 LaptopTop 10 Laptops 2014  Top 10 Business Laptops 2014   Source: http://www.pcmag.com/article2/0,2817,2362039,00.asp … Read More
  • Top 10 Best PrintersTop 10 Best Printers Source: http://www.pcmag.com/article2/0,2817,2373165,00.asp… Read More
  • Unroot Google Nexus 7 1. Install Nexus Root Toolkit http://www.wugfresh.com/nrt/ Select Appropriate Device and Software (Nexus 7v1, Androi 4.2) Waiting for downloading some .img from Google 2. Install Nexus success 3. Click Full Driver Ins… Read More

0 comments:

Post a Comment