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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:47:20+00:00 2026-05-22T14:47:20+00:00

Is it possible to have AJAX output to html, rather than plain-text? I have

  • 0

Is it possible to have AJAX output to html, rather than plain-text?

I have a file that pulls a class result from an SQL database. The database connection works, and it prints, but rather than printing the table format I desire, it simply prints the table elements as text on the page instead.

public class hw11
{
    int crn;
    String output = "temp";

    public String getOfferings(int crn)
    {
        this.crn = crn;     

        //DB Connection
        String url = "jdbc:odbc:registrar";
        Connection con;
        PreparedStatement stmt;

        String query;
        query = "SELECT * FROM offerings WHERE crn = " + crn +";";

        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        }
        catch(java.lang.ClassNotFoundException e)
        {
            System.err.print("ClassNotFoundException: ");
            System.err.println(e.getMessage());
        }

        try
        {
            con = DriverManager.getConnection(url, "", "");
            stmt = con.prepareStatement(query);
            ResultSet rs = stmt.executeQuery();   

            output = "<table border='1'><tr>";
            output+= "<th>CRN</th><th>Course</th><th>Section</th><th>Dates</th><th>Times</th><th>Instructor</th><th>Room</th><th>Max Enrolled</th><th>Current Enrolled</th></tr>";

            while (rs.next())
            {
                String course = rs.getString("COURSE");
                String section = rs.getString("SECTION");
                String dates = rs.getString("DATES");
                String times = rs.getString("TIMES");
                String instructor = rs.getString("INSTRUCTOR");
                String room = rs.getString("ROOM");
                int enrollmax = rs.getInt("ENROLLMAX");
                int enrollcur = rs.getInt("ENROLLCURRENT");

                output += "<tr>";
                output += "<td>"+crn+"</td><td>";
                output += "<td>"+course+"</td><td>";
                output += "<td>"+section+"</td><td>";
                output += "<td>"+dates+"</td><td>";
                output += "<td>"+times+"</td><td>";
                output += "<td>"+instructor+"</td><td>";
                output += "<td>"+room+"</td><td>";
                output += "<td>"+enrollmax+"</td><td>";
                output += "<td>"+enrollcur+"</td><td>";
                output += "</tr>";
            }

            output += "</table>";

            stmt.close();
            con.close();
        }

        catch (SQLException ex)
        {
            System.err.println("SQLException: " + ex.getMessage());
        }     


        //Output
        return output;
    }

}

HTML Page:

<p>

Get Course Offerings
<br/><br/>

Course CRN: <input type="text" id="theCrn"/>
<input value="Send" type="button" onclick="update()"/>

<br/>Reply:<br/>
<span id="theReply"></span>

</p>
  • 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-22T14:47:20+00:00Added an answer on May 22, 2026 at 2:47 pm

    Yes, you can return anything in response to an ajax call.

    Just make sure you append it properly to the page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read that ajax fileupload is not possible. But I want to upload
Is it possible to have multiple classes that inherit/extends same class in Google AppEngine
I have cgi script pulling search terms from an HTML form through CGI::Ajax .
So i have this output generated from a jQuery function i built (ajax) which
Possible Duplicate: How to: Back button support “Ajax” I have a ASP.NET MVC implementation
Is it possible to have a relationship from a user table to a system
I have an AJAX request (using JQuery) that calls a PHP script which does
I am writing an application that converts an ajax xml response into html using
I have a web service that is willing to output gzip/deflated data. I've verified
Possible Duplicate: E-mail validation in php? please help I have Ajax sign up form.

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.