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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:19:38+00:00 2026-06-18T16:19:38+00:00

I GET a HTML response from AJAX over cors and the response is a

  • 0

I GET a HTML response from AJAX over cors and the response is a table. Each category has its title and sub elements. The title names vary quite a bit and are likely to change in the future. The sub elements in each title change almost on a daily basis, but the DOM structure doesn’t.

Is there a way I could get rid of this if statement and replace it with code that isn’t element specific? Some way of selecting DOM elements I’m not aware of?

Relevat JS

    classifiedFilter: function( response ) {
            var Classified = {
                ClaAdministrative: [],
                Paraeducator: [],
                Clerical: [],
                Custodial: [],
                NonRep: [],
                Maintenance: [],
                ClaSubstitute: [],
                Coaching: []
            },
                response = $(response).find("table tbody tr td").html();
            $(response).find("#isHeadType").remove();
            $(response).find("font:contains(Open to all)").parent().parent().remove();

            //Filter each span title and classify sub items
            $(response).find("span").parents("tr").each( function() {

                //Find categories and separate by class
                var rowtext = $(this).find("span").text(),
                    position = "";

                position = rowtext.replace(/-/gi, "").replace(/\s/g, "");

                $(this).nextAll("tr").addClass(position);

                //Push content into Classified
                ((position === "Administrative") ? $(this).nextUntil(".Paraeducator").each( function() {
                    Classified.ClaAdministrative.push( $.trim( "<tr>" + $(this).html() + "</tr>" ) );
                }) :
                ((position === "Paraeducator") ? $(this).nextUntil(".Clerical").each( function() {
                    Classified.Paraeducator.push( $.trim( "<tr>" + $(this).html() + "</tr>" ) );
                }) :
                ((position === "Clerical") ? $(this).nextUntil(".Custodial").each( function() {
                    Classified.Clerical.push( $.trim( "<tr>" + $(this).html() + "</tr>" ) );
                }) :
                ((position === "Custodial") ? $(this).nextUntil(".NonRep").each( function() {
                    Classified.Custodial.push( $.trim( "<tr>" + $(this).html() + "</tr>" ) );
                }) :
                ((position === "NonRep") ? $(this).nextUntil(".Maintenance").each( function() {
                    Classified.NonRep.push( $.trim( "<tr>" + $(this).html() + "</tr>" ) );
                }) :
                ((position === "Maintenance") ? $(this).nextUntil(".Substitute").each( function() {
                    Classified.Maintenance.push( $.trim( "<tr>" + $(this).html() + "</tr>" ) );
                }) :
                ((position === "Substitute") ? $(this).nextUntil(".Coaching").each( function() {
                    Classified.ClaSubstitute.push( $.trim( "<tr>" + $(this).html() + "</tr>" ) );
                }) :
                ((position === "Coaching") ? $(this).nextAll().each( function() {
                    Classified.Coaching.push( $.trim( "<tr>" + $(this).html() + "</tr>" ) );
                }) : [] ) ) ) ) ) ) ) );
            });

            //remove title from array
            Certificated.Elementary.shift();
            Certificated.MiddleSchool.shift();
            Certificated.HighSchool.shift();
            Certificated.K12.shift();
            Certificated.Substitute.shift();
    }

Summarized HTML GET response (added spaces for visual aid)

    <table border="0" cellspacing="0" cellpadding="0" style="MARGIN-TOP: 10px;">
    <tr>
        <td>
            <font class="HeadTitle">External Positions: Open to all applicants.</font><br>
        </td>
    </tr>






        <tr>
            <td height="20" nowrap="nowrap">
                <i><span id="ExternalJobs__ctl1_BargainGroup" class="BodyText">Administrative</span></i>
                <br/><br/>
            </td>
        </tr>

                <tr>
                    <td nowrap="nowrap" style="padding-left:20px;" class="BodyText">
                          <b><a href='jobs.aspx?id=3660&type=2&int=External'>Administrative Assistant I, Health Tech-Leave Replacement-2 hours  -   ME1214</a></b>
                    </td>
                </tr>






        <tr>
            <td height="20" nowrap="nowrap">
                <i><span id="ExternalJobs__ctl2_BargainGroup" class="BodyText">Paraeducator</span></i>
                <br/><br/>
            </td>
        </tr>

                <tr>
                    <td nowrap="nowrap" style="padding-left:20px;" class="BodyText">
                          <b><a href='jobs.aspx?id=3544&type=2&int=External'>Paraeducator, SpEd IP/ELL-6.5hours -   MC1223</a></b>
                    </td>
                </tr>

                <tr>
                    <td nowrap="nowrap" style="padding-left:20px;" class="BodyText">
                          <b><a href='jobs.aspx?id=3603&type=2&int=External'>Special Ed Paraeducator, School Adjustment Program (SA-)-6.5 hours -   MK1215</a></b>
                    </td>
                </tr>






        <tr>
            <td height="20" nowrap="nowrap">
                <i><span id="ExternalJobs__ctl3_BargainGroup" class="BodyText">Clerical</span></i>
                <br/><br/>
            </td>
        </tr>               
                <tr>
                    <td nowrap="nowrap" style="padding-left:20px;" class="BodyText">
                          <b><a href='jobs.aspx?id=3481&type=2&int=External'>Admin Assistant IV-8 hours -   IT1209</a></b>
                    </td>
                </tr>   







        <tr>
            <td height="20" nowrap="nowrap">
                <i><span id="ExternalJobs__ctl5_BargainGroup" class="BodyText">Non-Rep</span></i>
                <br/><br/>
            </td>
        </tr>

                <tr>
                    <td nowrap="nowrap" style="padding-left:20px;" class="BodyText">
                          <b><a href='jobs.aspx?id=2732&type=2&int=External'>Licensed Practical Nurse (Pool position)   -   2012LPNPool</a></b>
                    </td>
                </tr>

                <tr>
                    <td nowrap="nowrap" style="padding-left:20px;" class="BodyText">
                          <b><a href='jobs.aspx?id=3472&type=2&int=External'>Certified Occupational/Physical Therapist Assistant- POOL  -   COTA2012Pool</a></b>
                    </td>
                </tr>







        <tr>
            <td height="20" nowrap="nowrap">
                <i><span id="ExternalJobs__ctl7_BargainGroup" class="BodyText">Substitute</span></i>
                <br/><br/>
            </td>
        </tr>

                <tr>
                    <td nowrap="nowrap" style="padding-left:20px;" class="BodyText">
                          <b><a href='jobs.aspx?id=26&type=2&int=External'>Substitute Food Service Helpers  -   FSSub</a></b>
                    </td>
                </tr>

                <tr>
                    <td nowrap="nowrap" style="padding-left:20px;" class="BodyText">
                          <b><a href='jobs.aspx?id=28&type=2&int=External'>Substitute Custodians    -   MTSub</a></b>
                    </td>
                </tr>
</table>
  • 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-18T16:19:40+00:00Added an answer on June 18, 2026 at 4:19 pm

    This seems equivalent to the core of your current code:

    $(this).each( function() {
        Classified[position].push( $.trim( "<tr>" + $(this).html() + "</tr>" ) );
    });
    

    [Edit] I don’t see where you declare your arrays, you might actually need this:

    $(this).each( function() {
        Classified[position]=Classified[position]||[];
        Classified[position].push( $.trim( "<tr>" + $(this).html() + "</tr>" ) );
    });
    

    [Update] Based on the comments, this loop updates position whenever it hits a span:

    var position = "";
    $(response).find("tr").each( function() {
        var currentTR=$(this);
        // catch span if any
        var rowtext = currentTR.find("span").text().replace(/-/gi, "").replace(/\s/g, "");
        if (rowtext) {
            position = rowtext;
            Classified[position]=[];
        }
        // Collect rows
        Classified[position].push( "<tr>" + $.trim($(this).html()) + "</tr>" );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get an html response from a url string? Using this: #lang
I get a jQuery AJAX response from localhost with var ajaxsrc = $.ajax({type:GET, url:
I have a big database to get dynamically images from Ajax response. How could
I have a following javascript that I call from my _form.html.erb. $.ajax({ type: GET,
I have a problem with placing a result from ajax response into a html
I am dynamically creating a html table based on the JSON response from an
When I try to get the response from a php file using Jquery ajax,
i get some HTML it a as ajax response, and i need to get
I am inserting the HTML response from an AJAX call into my page, but
I am trying to get the response from ajax call and save it in

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.