Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:09:16+00:00 2026-06-13T12:09:16+00:00

im using $.each to get the data from php via ajax but when i

  • 0

im using $.each to get the data from php via ajax but when i used it my browser saying this error Uncaught TypeError: Cannot read property ‘length’ of null, cant find any answer.

 $('#search-button-applicant').click(function (){
             date_to = Date.parse($('#search-to-date').val());
            date_from = Date.parse($('#search-from-date').val());

            applicant_name = $('#search-applicant-name').val();




             if($('#search-to-date').val() == "" && $('#search-from-date').val() == "" && applicant_name == ""  )
            {
                 alert("you can not search");

            }

             else if($('#search-to-date').val() != "" && $('#search-from-date').val() == "" ||  $('#search-to-date').val() == "" && $('#search-from-date').val() != ""){

                 alert("you can not search");
            }

            else{
                   var date_to_val = $('#search-to-date').val();
                   var date_from_val = $('#search-to-date').val();
                   var loan_type_val = $('#loan-type').val();
                   var search_word_val = $('#search-applicant-name').val();



                 $.ajax({
                     type: "post",
                     url: "filter_search_window_get.php",
                     dataType:'json',
                     data: {'func_num':loan_type_val,'Date_To':date_to_val,'Date_From':date_from_val,'search_word':search_word_val},
                     success: function(data){

                            $.each(data, function(i, item) {
                               $('#search-table-content-list').append("<tr><td style='width:7.5%;'><label>Date Filled</label></td><td style='width:9.5%;'><label>Date Released</label></td><td style='width:8%;'><label>"+data[i].last_name+"</label></td><td style='width:25%;'><label>Name</label></td><td style='width:7.5%;'><label>Term</label></td><td style='width:7.5%;'><label>Rate</label></td><td style='width:7.5%;'><label>Principal</label></td><td style='width:7.5%;'><label>Interest</label></td><td style='width:7.5%;'><label>Total</label></td></tr>");
                              });   

                            }
                     });
            }
        });

php:

$date_from = $_POST['date_from_val'];
$date_to = $_POST['date_to_val'];
$search_word = $_POST['search_word_val'];
$loan_type =$_POST['loan_type_val'];


switch ($loan_type){

case '1':

    tuition_get();

break;

case '2':
    salary_get();

break;

case '3':
    sss_get();

break;

case '4':
    ofw_get();

break;

case '5':
    business_get();

break;
}

function tuition_get(){
$date_from = $_POST['date_from_val'];
$date_to = $_POST['date_to_val'];
$search_word = $_POST['search_word_val'];

$query = "SELECT 
                                    a.applicant_id,
                                    a.last_name,
                                    a.first_name,
                                    a.created_date,
                                    b.form_type,
                                    b.form_id,
                                    c.stat,
                                    d.release_date,
                                    f.payment_term,
                                    j.form_rate,
                                    k.loan_amt,
                                   k.interest_amt,
                                    k.total_amt
                        FROM 
                                    applicant a
                        LEFT JOIN form_type b ON (a.form_id = b.form_id)
                        LEFT JOIN form_status c ON (c.status_id  = a.status_id)
                        LEFT JOIN applicant_loan_repayment d ON (d.applicant_id  =  a.applicant_id)
                        LEFT JOIN applicant_tuition_loan_dtl f ON (f.applicant_id  = a.applicant_id)    
                        LEFT JOIN form_term j ON (j.form_id  = a.form_id)
                        LEFT JOIN applicant_loan_repayment k ON (k.applicant_id  = a.applicant_id)

                        WHERE a.last_name LIKE '%$search_word%' OR a.first_name LIKE '%$search_word%' ";


             $result=mysql_query($$query)or die(mysql_error());



             $data=array();
                while ($row = mysql_fetch_array($result))
                {
                $data[] = array(
                    'last_name'=>$row['last_name'],
                   'first_name'=>$row['first_name'],
                   'form_typ'=>$row['form_type']
                );
            }


        echo json_encode($data);


}

 function salary_get(){
    $date_from = $_POST['date_from_val'];
    $date_to = $_POST['date_to_val'];
    $search_word = $_POST['search_word_val'];


}


function sss_get(){
    $date_from = $_POST['date_from_val'];
    $date_to = $_POST['date_to_val'];
    $search_word = $_POST['search_word_val'];


}


function ofw_get(){
    $date_from = $_POST['date_from_val'];
    $date_to = $_POST['date_to_val'];
    $search_word = $_POST['search_word_val'];


}


function business_get(){
    $date_from = $_POST['date_from_val'];
    $date_to = $_POST['date_to_val'];
    $search_word = $_POST['search_word_val'];


}

im using $.each to get all the fetch data from the query and post it in a table using ajax but my $.each is not working properly and i dunno whats wrong with my code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:09:17+00:00Added an answer on June 13, 2026 at 12:09 pm

    It looks like you are posting a parameter named func_num via ajax, but trying to read it in php as loan_type_val.

    Furthermore, all the data you are passing appears to be named differently than what you’re attempting to read on the server-side.

    If you’re trying to send via post:

    'func_num':loan_type_val,
    'Date_To':date_to_val,
    'Date_From':date_from_val,
    'search_word':search_word_val
    

    Your PHP server-side would have to be:

    $loan_type = $_POST['func_num'];
    $date_to = $_POST['Date_To'];
    $date_from = $_POST['Date_From'];
    $search_word = $_POST['search_word'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my index file I get data from the database using this function (which
I'm using Jquery and Ajax function to get data from MySql and put it
Hi I am using jquery to get data from mysql. It works wonderfully but
I'm trying to recursively get some data using connect by, which for each row
Is there anyways to get first two element of each profile_id using php array(
I'm using DataTables ( datatables.net ) to display data from an Ajax source and
I initially create a table using some data loaded from a php mySQL query.
I'm using join to query data from two tables. For each a_id I need
I'm using getJSON to get data from the facebook pages api, and it works
I am using phpQuery to get the data from elements. I'm trying to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.