Jump to content

adding data using PHP code


jimfog

Recommended Posts

I am constructing a form where the user will have to put some data-service specifically. Would you bother doing that with server code or just use only javascript and forget server code? I am not talking here about form validation although we are dealing also here form inputs. My thoughts are that accomplishing this with server code will be a bad user experience. All these requests going between the server and the client... And I should stick only with javascript. I am motivated also by the fact that similar pages--were much data must be entered-such as facebook "edit profile" page work only with js. What do you think?

Link to comment
Share on other sites

facebook edit page does not work only with JS. it has PHP in backend to work with the data. JS (AJAX) is used to pass the data to server. after that the data is handled normally as it would do with normal http request

Link to comment
Share on other sites

Yes...you are right, (I did not say it correctly)but if the user disables js in his computer he will not be able to fill the data. Anyway...from you answer, as I understand it. I must also make the PHP code AND the js/AJAX code. Am I correct?

Edited by jimfog
Link to comment
Share on other sites

yes. but i am not sure what is the exact question?

Link to comment
Share on other sites

there is no reason your form can't work with JS disabled. forms will still submit without JS. you can JS (if enabled) to hook into the submit event and provide any client side features like pre-validation. You should still be doing your due diligence on the server side as well.

Link to comment
Share on other sites

yes. but i am not sure what is the exact question?
You answered my question.
there is no reason your form can't work with JS disabled. forms will still submit without JS. .
Facebook "edit profile" page DOES NOT work without javascript. Yes it needs PHP code as birbal mentioned but js is a must. And to conclude.I want the user to be able to add services. I am going to use js to achieve that, it offer better UX experience. The question is that do i ALSO do that with PHP or just say to the user the usual "you have to enable javascript" message.So we are dealing here with a specific type of form submitting. Not just entering a name, password etc.Imagine the user entering 20 or so services.
Link to comment
Share on other sites

You can make a fallback to php. like you can set a event handler on submit button it will send an ajax request and returns false (which will prevent default behaviour of submit button). your action attribute of form should be same as you would do without any JS (when you request using AJAX you will get the action attribute from the form and parse it to make a request header). so in case JS is disabled submit button wont return false and the form will work as usual. same can be done in other case like adding textarea dynamically. in which case if js is disabled php will add textarea and response with the whole HTML.

  • Like 1
Link to comment
Share on other sites

Then...why do you think the "edit profile" in facebook does not work with js disabled? Why they have not provisioned for PHP fallback? I do not expect from you to know how facebook people decided to do it like this but only ti listen some thoughts.

Link to comment
Share on other sites

The distinction may be that Facebook is more of web application, and to that extent may have justified their full commitment to depending on having JavaScript enabled.

Link to comment
Share on other sites

I think the reason for that is some facebook some core feature is tightly dependent on JS (imagine news feed does not update realtime friend interaction which was main concept of FB to know what friends are doing). so it make JS mandatory even where fallback would do the same job without much of cons. Yes it is possible to simulate realtime update by non JS method but those would not be optimised or user friendly. Its more about UX. Also now these days it is more likely unusual to not having JS support or JS disabled in modern browser for desktop. Also facebook has less UX feature rich web site for old mobile access which does not depend on JS (Which is kind of fallback itself). They want to access the website exactly how they wanted to be. If you want to use it, you can't disable JS.

Link to comment
Share on other sites

Since I am building a web app me to I am thinking seriously if I should follow the same route such as facebook or other sites that DO NOT work with Js disabled. My app is NOT such interactive like facebook but it is a single page app(which means heavy use of javascript) and many features will loose the user friendliness if they are done with server code also. Overall, with server code , my app will lose much of its responsiveness.For example it contains a calendar and imagine the user picking/creating eventswith server code...it will be sluggish. What do you think now I gave you some more details about my app.

Link to comment
Share on other sites

You can deploy a fallback without much of effort if you plan it well. so why not give a chance to user for graceful degradation. your user still can use the app even if they don't have JS (like mobile users). you can set a warning message though to notify user that they are using degraded version of your site.

Edited by birbal
Link to comment
Share on other sites

You can deploy a fallback without much of effort if you plan it well. so why not give a chance to user for graceful degradation. your user still can use the app even if they don't have JS (like mobile users). you can set a warning message though to notify user that they are using degraded version of your site.
Υοu have a point in what you say. I did not know mobile does not support JS. Meaning that I must also build a native app for such platforms.Of course the only issue, is the extra effort, it took me a lot of time to build the server side validation functions of my form(which is not smal)-now I have to do it also in js. But that is inevitable... So, concluding, IS this the workflow for a form with both js and php validation.
  1. JS client validation
  2. AJAX call to the server to transfer the data
  3. Server-side validation

Are the above correct?

Link to comment
Share on other sites

I'm pretty sure mobile/tablet devices support JS, at least all the ones I've had to test for at work* iOS* Android* blackberry* KindleAnd this comes from the context of developing an Angular application, that would be nothing without JS support.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...