duanmei1536 2017-03-04 05:29
浏览 26

AJAX:在单独的调用中动态加载来自同一个php的数据吗?

I have an HTML/PHP/JQUERY/MYSQL web application. It's an HTML Bootstrap base, and jquery and other libraries plus my custom scripts, in front.

backend, i have several php files to serve the data.

For this example, say I have a CONTACTS php page where I need to display several data sets: 1) List of contacts 2) List of groups 3) list of tags associated with contacts

I have a backend php file in: engine/contacts.php

this is the php script that serves the contacts data as requested based on GET flags, eg:

engine/contacts.php?list=contacts
engine/contacts.php?list=groups
engine/contacts.php?list=tags

Sure i could serve them up in one call but , by design, each part of the web page (contacts, or groups, or tags) are separate datasets, and this way, if one data set is updated, i can refresh that part only.. eg: user adds a group , then JS will ajax load:

engine/contacts.php?list=groups

to update the groups area (div)

So, basically, ON PAGE LOAD 3 separate JS calls are fired at the same time load data from the same contacts.php file

IS THIS AN OK Practice? I mean it should be because I see lots of sites doing the same .

And how does this impact the server side? Will the server execute this php file one at a time? will it be better if i separate the files? like:

contacts.php
contacts_groups.php
contacts_tags.php

and simultaneously call them?

The reason I ask is because I'm currently debugging some performance issues. Simply put, i have very light weight PHP/MYSQL web application with HTML5/Jquery front end. The datasets being handled is very minimal and the database tables having less than 50rows

But somehow my application is hitting resource limits on the shared host server, particularly on the 1GB RAM limit side. And i have reproduced this situation on a stand alone domain w/ no other users and it's still hitting the limits.

I have gone through the php scripts and can't find anything. I do have loops, yes, but they are thoughtfully done and terminates after a few iterations.

I'm out of ideas so I'm just trying to explore what else i can poke at.

Would appreciate some guidance, thanks

  • 写回答

1条回答 默认 最新

  • dongzhang1864 2017-03-04 06:01
    关注

    I think, if you use an OOP structure you can consider a method for handling each request in backend. Although the best way is to use a MVC framework to dispatch the requests with URL routing to special methods :

        engine/contacts/contacts
        engine/contacts/groups
        engine/contacts/tags
    
    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助