Jump to content

jQuery or ajax get


Mudsaf
 Share

Recommended Posts

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

"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

 

 

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

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 by Mudsaf
Link to comment
Share on other sites

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

  • 1 year later...

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

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

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
 Share

×
×
  • Create New...