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 4324444
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:08:00+00:00 2026-05-21T09:08:00+00:00

I am using an ajax function to receive data. Based on that data, if

  • 0

I am using an ajax function to receive data. Based on that data, if results are not found I receive a string “No matches found” with some html formatting. If there are results, data is formatted into a table and a “Div” section underneath this section is hidden.

Now the issue I am having is, when I find no results, i do not want this “Div” table to disappear.But to check if there are no results, I would have to compare the whole string received by the searchCustomer.php (which is very large).

Is there an easier way of doing this?

My ajax call:

$('#search').click(function(e){
        $.ajax({
            type : 'GET',
            url : 'searchCustomer.php',
            dataType :'html',
            data:{
                lastName : $('#search_LN').val(),
                firstName : $('#search_FN').val(),
                phone : $('#search_PN').val()
            },
            success : function(data){
                if (data.error == true){
                    alert("there was an error in the post layer");
                } else {
                    $('#searchResults').html(data);



                if (data.text == '<br><font color='red'>No matches found</font>'){
                }else{
                var ele = document.getElementById("NewCustomerDiv");
                ele.style.display = "none";
                }
            }
        }
    });
    return false;
});

Running fire-bug,
The actual data received from searchCustomer.php is:

<style type="text/css">
a.resultBookButton {
    color: black;
    padding: 1px;
    border: 2px outset lightgrey;

    background: #008800;
    /* Mozilla: */
    background: -moz-linear-gradient(top, lightgrey, #FFFFFF);
    /* Chrome, Safari:*/
    background: -webkit-gradient(linear,
                left top, left bottom, from(lightgrey), to(#FFFFFF));

    text-decoration: none;
}

a:active {
    border-style: inset;
}
</style>

<br><font color='red'>No matches found</font>

I just want to check for “No matches found” or if there is a better way of finding no results.

  • 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-05-21T09:08:00+00:00Added an answer on May 21, 2026 at 9:08 am

    I disagree with Brad, converting to JSON would be a pain because all your HTML which uses quotes all the time would have to have those quotes escaped in order to work in a JSON string, which can present an annoyance at best and accidentally trigger errors for invalid JSON at worst.

    The ideal solution is changing what those pages return. Return the full HTML if items found, return “0” or “” if nothing is found, and then check for those returns.

    If you can’t change what is returned from the AJAX call, perhaps just do an (returnedData.indexOf(”

    Easy peasy.

    EDIT:

    $.ajax({
          ... other setting ...
            success : function(data){
               (data.indexOf('<table') == -1){
                    //there was a table in the returned data
               } else {
                    // ...
               }
            }
          });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some content from server using $.ajax() function. I try to replace some
I'm using the JQuery AJAX function to deliver data to a PHP doc. Currently,
I'm using ajax to make a request on a servletand receive json String servlet
I am using Ajax to receive a JSON update: $(document).ready(function(){ $('form').submit(function(event){ event.preventDefault(); var form
How to pass multiple checkboxes using jQuery ajax post this is the ajax function
I am using the $.ajax function in jquery to make a call to an
Using the following JQuery/AJAX function I'm calling a partial view when an option is
I am using the jQuery $.ajax() function. I have put this into a parent
I am using the below jquery code to call a ajax function in my
I wish to execute a javascript function after asp.net postback with out using ajax.

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.