PHP value to JS, can not echo it?

Source: Internet
Author: User
Tags mysql command line
Title, using the JSON pass value, because the record is more, with echo too time-consuming, please master pointing


Reply to discussion (solution)

Why do you think it's too time-consuming to use echo?

Can be serialized or JSON encoded, then echo;

echo Json_encode ($array);

Because the database query results more records, together to the Ajax, the front-click Query response is too slow, do not know how to engage

Can be serialized or JSON encoded, then echo;

echo Json_encode ($array); $result =mysqli_query ($DBC, $query);
$amount =mysqli_num_rows ($result);
$jsonresults =array ();
while ($row =mysqli_fetch_array ($result)) {
$jsonresults []= $row; }

$jsonresult =json_encode ($jsonresults);

Echo $jsonresult;
This is my PHP code, has been converted, but the record is more, about two seconds after the query only response (nearly 3,000 array records)

There is a question.
LZ what is the execution time if I typed $dbc content in MySQL command line?
It doesn't have to be a PHP parsing problem. It could be the time it takes to read data.

There is a question.
LZ what is the execution time if I typed $dbc content in MySQL command line?
It doesn't have to be a PHP parsing problem. It could be the time it took to read the data. I tried it this way, echo $jsonresult; First change to a comment, and then use echo "a", to replace, display to the foreground, this time is much faster, the front of the read has not changed

3,000 array records, 2s is very fast, okay. Does it take a little time to convert 3,000 array records into JSON?

3,000 array records, 2s is very fast, okay. Does it take a little time to convert 3,000 array records into JSON? There should be a better way, I see someone do, more than 10,000 sets of results in an instant out of the amount

echo "a"; To replace the Echo $jsonresult; It's a lot faster.
That means the front desk problem, of course, only echo "a"; The front desk is going to be wrong.

foreground rendering of * N HTML objects doesn't it take time?

echo "a"; To replace the Echo $jsonresult; It's a lot faster.
That means the front desk problem, of course, only echo "a"; The front desk is going to be wrong.

Foreground rendering * N HTML objects don't you need time? It is possible, because the front desk to pass the results of the past Eval, I use echo "a"; Instead of the time to change these to comments, may be the eval is more time-consuming, moderator greatly, there is a way to improve the next, want speed faster

Do you have to check 3000 records at once? If not necessary, can be obtained in batches based on user behavior

You might consider loading it in batches, like the waterfall flow.
* N Data how there will be a scroll bar, that is impossible to see all of a sudden
First see the load first, then see after loading, this is called "Waterfall Flow"

Let's split the page. Too many browsers are cards.

You might consider loading it in batches, like the waterfall flow.
* N Data how there will be a scroll bar, that is impossible to see all of a sudden
First see the first load, then see after loading, which is called "Waterfall Flow" I am using the Ajax, point query each time a record is displayed, a record is an HTML table, and then the next page on the previous page does not have to refresh the page, when the switch record quickly, time can be ignored, Is the initial point of the query will wait a while, this situation is applicable to batch loading?

Batch loading completely no problem, where do you get all the data to the front desk? A large number of visits, your server is not dead?

Thank you, knot stickers!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.