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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:30:28+00:00 2026-05-25T20:30:28+00:00

I have PHP file named content.php prepared for both kind of requests, just as

  • 0

I have PHP file named “content.php” prepared for both kind of requests, just as an example:

<?php
  // Id params passed via GET method
  $get = $_GET['param'];
  switch ($get) {
    case "param_value":
?>
  <div data-param="<?php echo $get; ?>">
    // My HTML content here
  </div>
<?php
      break;
    case default:
      break;
  }

  // Id params passed via POST method
  $post = $_POST['param'];
  if ($post != "") {
    $data['output'] = '
      <div data-param="<?php echo $get; ?>">
        // My HTML content here
      </div>
    ';
    echo json_encode($data);
  }
?>

And than I have Javascript file, from which I am making an AJAX call to PHP:

var oWrapper = jQuery("#wrapper"),

// Loading HTML via jQuery.load() function
    sParams = jQuery.param({ param: "value" });
oWrapper.load("/content.php?" + sParams, function () {
  console.log("content loaded via load()");
});

// Loading HTML via jQuery.ajax() function
jQuery.ajax({
  type: "POST",
  dataType: "json",
  url: "/content.php",
  cache: false,
  data: { "param": "value" },
  success: function (data) {
    oWrapper.html(data.output);
    console.log("content loaded via ajax()");
  }
});

Which way is faster?

Besides the speed of requests and returns, I wish to know which way is better for security of the app?!

  • 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-25T20:30:28+00:00Added an answer on May 25, 2026 at 8:30 pm

    Both ways do pretty much exactly the same thing.

    Internally, $(selector).load() uses $.ajax() to get the data, then $(selector).html() to set the html of the selected element to the response of the $.ajax() call.

    If you are loading html into an element, use $(selector).load() because it is more readable. One is just as secure and as fast as the other.

    Note: Internally jQuery now uses $.parseHTML() rather than $(selector).html() to convert the string to html. This doesn’t really change anything though.

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

Sidebar

Related Questions

I have a file named graph.php on my server that reads dynamic content from
I have a php file that holds my login details named connect.php. $host =
I have a file named discussion.php , where a form is located. In this
I have a php file generating XHTML content and I use <?php header('Content-type: application/xhtml+xml');?>
I have created a file name database.php and here is it's content <?php #Start
I have this csv named test.csv with the content below 1,test user,,,4075619900,example@example.com,Aldelo for Restaurants,this
I have the following mail.php file : <?php $name = $_POST['name']; $to = $_POST['to'];
I have this HTML: <form action='uploadhandle.php' method='POST' enctype=multipart/form-data> <input type='file' class='fileinput' id='photo1' name='photo1'> <input
I have an upload box... <form action=upload_file.php method=post enctype=multipart/form-data><BR> <label for=file>Filename:</label><BR> <input type=file name=file
I have a PHP file which will return something like <div id=title>Add Us On

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.