Questions about javascript language

0

Good morning!

Personally, I'm a beginner in javascript and I have some questions about the following snippet:

var url;
function newUser(){
  $('#dlg').dialog('open').dialog('setTitle','Novo Cliente');
  $('#fm').form('clear');
  url = 'salvar_cadastroclientes.php';
}
function saveUser(){
  $('#fm').form('submit',{
    url: url,
    onSubmit: function(){
      return $(this).form('validate');
    },
    success: function(result){
      var result = eval('('+result+')');
      if (result.success){
        $('#dlg').dialog('close');		// close the dialog
        $('#dg').datagrid('reload');	// reload the user data
      } else {
        $.messager.show({
          title: 'Erro',
          msg: result.msg
        });
      }
    }
  });
}

In the save function, the code is capturing submit of form .

And in the second line, what is this url: url , onSubmit ...?

    
asked by anonymous 22.12.2015 / 13:10

1 answer

0
**url:** *url,*

The first url is the name of an attribute. In your case the .form object has 2 attributes: **url:** e **onSubmit:** url: is getting the variable url, However I believe that an error must occur because in the scope of the function saveUser () {...} the variable url was not defined, but it was in

function newUser(){ ... url = 'salvar_cadastroclientes.php'; }

    
22.12.2015 / 13:30