2014-08-05

Javascript: how to scroll automatically to a certain area of the page

document.getElementById("anchor-div").scrollIntoView();

Skeleton AJAX call with JQuery

var array_info = {};
  array_info['key1'] = $("#field1").val();
  array_info['key2'] = $("#field2").val();
  var array_info_json = JSON.stringify(array_info);
 
 //ajax call
 $.ajax({
        url: "file.php",
        type: "POST",
        data: {
            action: "parameter",
            field_data: array_info_json
        },
  
        success: function (data) {
            console.log(data);
            if (data != '') {
                $('#div_container').html('Sucess');
                dataArray = JSON.parse(data);   
            }
            else{
            
                alert('No data');
            

            }
        },
        error: function (a,b) { 
                alert('Error');
      }
    });