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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:21:22+00:00 2026-06-12T07:21:22+00:00

I have following ajax call and response with json data type. Currently I write

  • 0

I have following ajax call and response with json data type. Currently I write the data and html tag directly in js but I think this is not good and hard to read. How can I pass them in Codeigniter view?

$.ajax({
        type: "POST",
        url: baseUrl + "profile/setting",
        dataType: 'json',
        success: function(data){
          var html = "";
          html += "<div>";
          html += "<img src=\"" + baseUrl + data.picture + "\" />";
          html += "<div>" + data.email + "</div>";
          html += "<div>" + data.first_name + " " + data.last_name  + "</div>";
          html += "<div>" + data.address + "</div>";
          html += "<div><input type=\"text\" class=\"input_text_top\"/></div>";
          html += "<div><input type=\"text\" class=\"input_text_middle\"/></div>";
          html += "<div><input type=\"text\" class=\"input_text_bottom\"/></div>";
          html += "<div><input type=\"submit\" class=\"btn btn_grey\"/></div>";
          html += "</div>";
          $('#result_column').removeAttr('style').html(data);
        }
      });
  • 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-12T07:21:23+00:00Added an answer on June 12, 2026 at 7:21 am

    There are a couple of options for you:

    1. Generate the HTML from a CodeIgniter View:

    If you change your dataType attribute to dataType: 'html' you can have the server return a string of html which you can immediately inject into your #result_column.

    CodeIgniter’s $this->load->view() comes with a third boolean parameter. It’s default is FALSE. If you pass TRUE, the $this->load->view() function returns data instead of echoing it to the browser.

    What you can do is:

    $response = $this->load->view("your_ajax_view", $data, TRUE);
    //do anything you would need to with the response.
    echo $response;
    

    2. Use a templating system

    Like Mustache, Handlebars, EJS or Underscore to inject your returned json data into a custom template. This has the advantage of saving bandwidth because you only transfer the markup once (on initial page load) and from that point forward transfer data only.

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

Sidebar

Related Questions

I have following ajax call: $(#container).html(loading...); $.ajax({ url: somedoc.php, type: POST, dataType: html, success:
I have a following javascript that I call from my _form.html.erb. $.ajax({ type: GET,
I have the following ajax call to webservice to pass json data and get
I have a JSON response returning from an Ajax call but cannot seem to
I have the following code: $.ajax({ type: 'GET', url: 'index.php?route=checkout/onepagecheckout/getpaypaldata', dataType: 'json', success: function(json)
I have an ajax call that returns JSON data (Data Attached). After converting the
I have the following working Ajax call - $.ajax({ url: ajaxUrl, type: sendHttpVerb, dataType:
I have the following script in my javascript... $.ajax({ type: 'POST', url: 'http://www.example.com/ajax', data:
I have the following ajax call var prev_sibling = $(this).prev().attr(value); var next_sibling = $(this).next().attr(value);
The problem is the following. We have lots of ajax call via $.ajax function.

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.