how to use url and amin-ajax.php?

I am trying to redirect users back to a main page with a success message followed by a submit button with PHP and AJAX. However, users are sent to a blank page with the message. I believe it’s called admin-ajax.php. to do with the location of

Here is my code:

jQuery.ajax
            ({
                //data type that is being thrown around
                dataType: "json",
                // whether or not data is being posted or not
                type: "post",
                // serializing creates a URL encoded text string
                data: jQuery("#myForm").serialize(),
                // this is the location in which the url takes the data
                url: "../admin-ajax.php",
                success:function(data) 
                {
                
                    jQuery(".messageDiv").html(data.message);
                    
                    if(data.status == 1)
                    {
                        jQuery("#myForm").trigger('reset');
                    }
                },

            });

Is "../admin-ajax.php" correct url? How does one interact with other pages without using header() function in php?

Leave a Comment