grab.js
//called when a submit event happens
called when a submit event happens
called when a submit event happens
function formSubmit(event){
  console.log('start saving form data');
  var list = {};
    for (index = 0; index < event.target.elements.length; ++index){
        if(event.target.elements[index].name === 'Branch'){          
          list[event.target.elements[index].name] = $.trim($("#Branch option:selected").text());
        }else{
          list[event.target.elements[index].name] = event.target.elements[index].value;
        }
    }
    var mydata  = {
      items: list,      
    }
    $.ajax({
      type: "POST",
      dataType: "json",
      url: "http://clinc.htc-nablus.com/api/web/v1/recipes/form?access-token=test&lang=ar",
      data: mydata,
      success: function(data){
          console.log(data);
      },
      error: function(xhr, textStatus, errorThrown){
      }
    });
}
function formSubmit ( event ) { console . log ( 'start saving form data' ) ; var list = { } ; for ( index = 0 ; index < event . target . elements . length ; ++ index ) { if ( event . target . elements [ index ] . name === 'Branch' ) { list [ event . target . elements [ index ] . name ] = $ . trim ( $ ( "#Branch option:selected" ) . text ( ) ) ; } else { list [ event . target . elements [ index ] . name ] = event . target . elements [ index ] . value ; } } var mydata = { items : list , } $ . ajax ( { type : "POST" , dataType : "json" , url : "http://clinc.htc-nablus.com/api/web/v1/recipes/form?access-token=test&lang=ar" , data : mydata , success : function ( data ) { console . log ( data ) ; } , error : function ( xhr , textStatus , errorThrown ) { } } ) ; }
called when a submit event happens
called when a submit event happens
// alert(textStatus);