Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Vapr_Arts

Thread: Ajax/js vs Php

  1. #1
    Senior Member Vapr_Arts's Avatar
    Join Date
    Oct 2013
    Location
    California
    Posts
    1,930
    Member #
    37412
    Liked
    544 times

    Ajax/js vs Php

    I am about to start working on a small project that will be worked on lightly during this semester. I want to create a way for me to upload images to a portfolio and create a dynamic photo gallery with a lightbox feature.

    I know how I am going to upload the files to the folders using Php GD. I am using Php GD so i can upload the image, create a thumbnail with a specified height and width and save both in different folders with corresponding names based on the title from an input on the upload form.

    The next step is to populate the gallery with thumbnails for each image in the thumbnail folder. Then when a thumbnail is clicked it will create a modal with the original sized photo and maybe some text.

    I am comfortable in the programming aspect of it. I can figure out HOW to do it. My question is which is more efficient. I feel like Php would be better for this as js can be disabled or unavailable on a device, but i noticed most people who have already done this have done it in js/ajax so I am curious if there is a reason why? Is it going to be taxing on the server? Is there any reasons why i shouldnt do this all in Php?


    Sent from my iPhone using Tapatalk

  2.  

  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    AJAX is Asynchonous Javascript And XML, which means two things: 1) It's a bit of a silly acronym since the "ML" isn't included, and 2) the responses you get back from AJAX aren't always XML-formatted. Yes, I said that. The simple example is retrieving responseText instead of responseXML:

    XML DOM - HttpRequest object

    Now, why is that significant? Because what you retrieve from AJAX can be regular HTML. You don't have to retrieve XML data. For example, you could retrieve the HTML for an image generated by the PHP GD.

    As far as why people do things like that using AJAX...and I'm one of those people...there are a few reasons:

    1) It's quicker for the user in that images can be generated and sent on the fly, or cached/stored for future delivery.
    2) It's quicker for the user in that a page doesn't have to be reloaded to generate the new image.

    Which leads to the answer to your last question: it may or may not be more taxing on the server than straight PHP calls. It depends on how efficiently you design what you're doing..."design" in this case meaning "develop the back-end code and create a front-end that is ideally friendly to your users."
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  4. #3
    Senior Member Vapr_Arts's Avatar
    Join Date
    Oct 2013
    Location
    California
    Posts
    1,930
    Member #
    37412
    Liked
    544 times
    Thank you for the insight. I started thinking about it last night and I think I can get it done in ajax fairly quickly so I may just create both options for myself to further my experience programming. I can then see which is lighter on the server and why not?


    Sent from my iPhone using Tapatalk
    TheGAME1264 likes this.

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    "Why not", indeed. Give it a go and see what happens.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Quote Originally Posted by TheGAME1264 View Post
    2) the responses you get back from AJAX aren't always XML-formatted.
    I don't think I've ever gotten XML back via AJAX. Just about everything sends either straight HTML/Text or JSON. I did take my sweet time learning AJAX, so that may be why.

    That said, Vapr, you would just about need to use both, since you're going to need a script on the backend to process the AJAX request anyway. If you're concerned about JS problems, or the user having it turned off, just create a script that creates the output and use it as a fallback.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  7. #6
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    I have, but usually it's because I created the page that sent the XML response, so I knew how it was formatted. I've also received JSON and "other".
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:50 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com