Showing posts with label ajax. Show all posts
Showing posts with label ajax. Show all posts

Friday, March 2, 2018

Undefined Values in JS is not posted In AJAX Requests





In following JS code
function saveLTDrowConv(parent){
                pad_id =$('select[name="department1"] option:selected').val();
                 year =$('select[name="ReviewYear"] option:selected').val();
                 Deanrecommd = parent.find('.term_CONV_Dean').val();
                 conv  = parent.find('.term_CONV').val();
                 fte = parent.find('.term_CONV_fte').val();
                 sfu_id  = parent.find('.sfuid').html();
                 var filter = {

                        "pad_id":pad_id,
                        "year":year,
                        "sfu_id":sfu_id,
                        "fte":fte,
                        "Deanrecommd":Deanrecommd,
                        "conv":conv

                }
                 parent.find('.ltd_CONV_row').attr('disabled','disabled');
                 $.post("/tracs/ajax/facultyHiringPlan_ajax/saveLTDrowConv",  {"post":filter
                        }, function(data) {
                 
                        parent.find('.ltd_CONV_row').removeAttr('disabled');

                        $("div#notice").html('Update successfully.');
                        $("div#notice").css('display', 'block');
                        $("div#notice").fadeOut(5000);  


                });
}

If  Deanrecommd is undefined and  we post Deanrecommd, the server will not receive
Deanrecommd. i.e no $post['Deanrecommd']  in server. So as to other post variables.

Friday, October 24, 2014

Using ajax in filter or search




Assume we have a form:
     <form id="filterForm">
            <input type="button" id='FilterButton' value="Filter" />
      </form>

We we click the Filter button
$(document).ready(function(){
    $('#FilterButton').click(function(){
            submitFilter();
    });


}
 submiteFilter function using ajax
function submitFilter(){
    $.post('handlesubmit.php', $("form#filterForm").serialize(), function(data) {
                formatJson(data, 'div.ajax_list', setDefaultContent);
         });
}


function setDefaultContent is used to handle the data from ajax post.
function setDefaultContent(formattedJson){

}