Add papameters to AJAX response and then apply actions based on return parameter
<p>I have a page (<code>page1</code>)that calls another page (<code>page2</code>) via AJAX.
How do I include parameters to page2 response and parse them in <code>success : function(data)</code>?
is there any way to add parameters to http response object and then access those parameters?</p>

<p>Reason:</p>

<p>page2 generates some HTML. It could be <code>good</code> or <code>bad</code> html message. If it is a good message, I need to add parameters (hidden) and then add that good message to <code>Success div</code>. if message is an error, I need to add this message to 'Error div'.</p>

<p>I can do it <code>bad way</code>: In Page2 I can add <code>hidden</code> element; then in page1 I can create some temp hidden div and add response to that div. Then access hidden element in hidden div and get it's value. Then get message from that div and paste it to designated div. But this seems to be too unprofessional. </p>

<p><strong>PAGE1:</strong></p>

<pre><code>                function registeruser(){

                    jQuery(function($) {    
                        $.ajax( {           
                            url : "page2.php",
                            type : "POST",
                            data: {
                                registerFname : document.getElementById('registerFname').value, 
                                registerLname : document.getElementById('registerLname').value,
                                registerLEmail : document.getElementById('registerEmail').value,
                                registerPassword : document.getElementById('registerPassword').value,
                                ts : (new Date().getTime())
                            },

                            success : function(data) {
                            //need to apply logic here based on the return parameters
                            //if (SOME_PARAMETER === 'success'){
                            // document.getElementById('registerPresentation').innerHTML = data;  
                            //}
                            //else {
                            // document.getElementById('registerPresentationErrorDIV').innerHTML = data;  
                            //}

                            //need to get rid of item below
                                document.getElementById('registerPresentation').innerHTML = data;   

                            }
                        });
                    }); 

                }
</code></pre>
