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

  • Home
  • SEARCH
  • 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 4617612
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:08:55+00:00 2026-05-22T02:08:55+00:00

I was wondering how you guys do a page rebuild with php and jquery.

  • 0

I was wondering how you guys do a page rebuild with php and jquery.
In my application i need to rebuild divs all the time.
So what i do is

  1. sending a ajax call with get for example person_controller.php?action=rebuild

  2. The controller makes a database query filling the fields of form.

  3. Now the div has created for example

    $div = '<table>
    <tr>
    <td>
    <label id="' . $id . '">' . $id .'</label>
    </td>
    </tr>
    </table>';
    return $div;

  4. On the succes function of the ajax call i do this : $('#Div').replaceWith(newdiv);

This works very fine, but i was wondering of this is the good method about rebuilding divs without page refresh.

Also in firebug you can see the whole div code within the get request.

Summarized: Is this a good way? Or need i to change my coding behaviour.

  • 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-22T02:08:56+00:00Added an answer on May 22, 2026 at 2:08 am

    This method is perfectly fine. It can have drawbacks from a developer perspective: it’s more difficult to browse the ajax response in firebug if it’s HTML as opposed to just data, and it will limit the reuse of your server-side script since it will only ever return a HTML table where in another case you may want the same data but in a different format.

    The alternative is to return just the data by itself in an array or object, and no HTML. Then you would construct the HTML on the client side. Typically people would do a database query for a row or an array of rows, then call json_encode to put it in JSON format, and then in the success callback of their javascript ajax call they would have a javascript object or array that they could pull the data out of ($id in your case) and generate the HTML.

    If you decide you want your ajax calls to transfer only data, and no HTML, then you may want to look into javascript templating. There are libraries such as Mustache that allow you to define templates and then pass the data from your AJAX call into the template and have it fill in placeholders. This is cleaner than concatenating strings together in Javascript.

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

Sidebar

Related Questions

I was wondering if you guys know how to get the date of currents
I'm wondering if you guys can help me to perform on-demand javascript using AJAX?
I was wondering if you guys know howto get the validationsummary title from resouce-file?
I have not submitted an application yet, however am wondering if you guys could
Hello guys I was wondering why some websites which uses php (or any other
Hi Guys just wondering if you could help, I have a page in C#
I was wondering how you guys actually develop large applications when you are your
When reading about SQL Injection and XSS i was wondering if you guys have
Hey guys I was wondering if someone could provide a little help. I've been
Just wondering if any of you guys know of any web-based/browser-based employee scheduling software/tools?

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.