Forums
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › How to separate PHP content returned in an AJAX Jquery POST function
I did something completely different now to separate the content returned by the Jquery POST callback…
In the callback, I receive just ONE echo and that is a confirmation that the user is logged on ( after running some backend PHP validation ). On this conformation I have a link that ( when clicked ) only refreshes the page, upon refreshing, the PHP Session will pick up that the user is logged on and display the content the user is allowed to see, by embedding the PHP tags and only echo’ing content based on the condition that the user’s Session exist.
Not sure if it is the most elegant way to do this, but it works for me.
Thanks for everyone’s input. Much appreciated.
Entry a bit old now, but thanks for your code stefanbar, I needed the same thing for my code.
I don’t really understand the use of this line:
header(‘Content-type: application/json’);
but it was necessary.
here’s a good tutorial that also uses the combination of PHP and AJAX, you can seach and the results are quick it also have limiters. http://www.upgradedtutorials.info/tutorials/fast-search-and-sorting-data-in-mysql-using-php-and-ajax/