Mudsaf Posted August 24, 2013 Share Posted August 24, 2013 Hello, i'm wondering atm if there is possibility to receive data from ajax or jQuery method without receiving full HTML page. Example if i use jQuery form plugin and submit data, i want to see if the post goes through correctly without any errors. Also i wan't to be user friendly if guest doesn't have JavaScript enabled the page works normally with all styles and other stuffs. Currently I've made blank PHP pages that writes data example "Success" and i check at JavaScript if the received html is "Success". Now i realized its very bad method to do that.jQuery form plugin http://malsup.com/jquery/form/ Link to comment Share on other sites More sharing options...
davej Posted August 26, 2013 Share Posted August 26, 2013 "Hello, i'm wondering atm..." What is this word "atm?" The whole idea behind Ajax is to send small amounts of data either from or to the client browser. Why do you now feel it is a "very bad method" to do that? Yes, you can write a page that will use "fallback" methods if Javascript is disabled or the Ajax object is unavailable. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 26, 2013 Share Posted August 26, 2013 Currently I've made blank PHP pages that writes data example "Success" and i check at JavaScript if the received html is "Success". Now i realized its very bad method to do that. Why do you think it is bad to do that? Ajax requests do not need to return a lot of data if they are not being asked for data. My ajax requests typically return a JSON object with properties for success, error messages, any data associated with the request, etc. If you're trying to have one page that works for both ajax and non-ajax requests, then pass it an extra parameter if it is an ajax request so that the page knows that and can return the ajax response, or else it returns a full response. Link to comment Share on other sites More sharing options...
Mudsaf Posted August 27, 2013 Author Share Posted August 27, 2013 (edited) Well as you know there is jQuery form plugin. If i don't have JavaScript enabled the page would display "Success" instead of whole website style. So i'm wondering is there possible to return a "small success" variable from the posted page to the page where its sent. No JavaScriptForm > Submit > Whole style & MessageJavaScriptForm > Submit > Message only "Hello, i'm wondering atm..." What is this word "atm?" The whole idea behind Ajax is to send small amounts of data either from or to the client browser. Why do you now feel it is a "very bad method" to do that? Yes, you can write a page that will use "fallback" methods if Javascript is disabled or the Ajax object is unavailable. atm = at the moment So basically what i'm searching here is i want to receive small variable or something from submit page so i can check what happened there without receiving full html code. Edited August 27, 2013 by Mudsaf Link to comment Share on other sites More sharing options...
justsomeguy Posted August 27, 2013 Share Posted August 27, 2013 I don't know how the form plugin works, but that's what I was suggesting. The regular form action should return an entire page. If the submit is handled with ajax then you should add an additional parameter to tell the server that it was submitted through ajax and return an ajax response. Link to comment Share on other sites More sharing options...
mfarrell Posted February 2, 2015 Share Posted February 2, 2015 I am considering trying to do something like this.... Data on one page (form) to be sent or read by another page as Java Script..so that I can separate the input form from the results page for clarity. Calculations page >>>> Feeds values to a graphical results page....at this moment I want to use a script IF possible as this is a local development with no 'server' side processes. Link to comment Share on other sites More sharing options...
thescientist Posted February 2, 2015 Share Posted February 2, 2015 I am considering trying to do something like this.... Data on one page (form) to be sent or read by another page as Java Script..so that I can separate the input form from the results page for clarity. Calculations page >>>> Feeds values to a graphical results page....at this moment I want to use a script IF possible as this is a local development with no 'server' side processes. Please start a new thread for a new topic you want to bring up. Please do not post inside someone else's thread. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now