php - Multiple responses from one AJAX request -


Actually the code is not looking for examples, just concepts

I now have three sections on this page Are being updated for PHP scripts through three different AJAX calls, which come back to JSON. What would be the easiest way to collect these three calls in a big call and get responses to the client in JSON? How do I differentiate the responses to the client, so I can manipulate based on the information that what information is sent back?

itemprop = "text">

I like the cruise method, but I think I can provide some improvement. As you already have 3 different entities, so that the need to reload everything can be reduced, you can include PHP in a code with a in a file 'page.php' And can be sent back to an object. JSON has given names of named properties (say "name", "dates", and "fuzzy tigh") for all of them. To send a request to your client code, you will have all 3 requested arguments being sent in a request individually JSON will return something like this (your objects / arrays / whatever in the comments area The essential stuff for the name goes here, the "dates": {/ * The essential items for the date go here * / / < }, "Fuzzy Tighings": {/ * All Fuzzy Things Go Here * /}}

Get it in the client side, as I think it may already be a function (or set of function) to deal with a return data before, you should be able to call them in this way: < / P>

  function handler (rate text) {var returned object = eval (retText); DoStuffWithNames (returnObject.names); DoStuffWithDates (returnedObject.dates); PlayWithFuzzyThings (returnedObject.fuzzyThings); }  

In addition, at the end of PHP, you can create a unified PHP page (without expected expectation):

   Note:  You may have to edit 3 php pages so that Check them $ _POST properly and do not interfere with the functionality of other pages if you do not already have one, I like the method of  if (isset ($ _ POST ['any']) { ...}  to check that all Something was sent correctly, in this way, you can include as many as you want, and if there is nothing to do with the php file (i.e. you are not using that section on that page ), It will return a blank property, and you will not use it (basically it is "One 

Hope it works for you!

< / Html>

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -