I am trying to submit form data to the current page to handle variables using jQuery. When I send a POST request, the server receives a GET request, and my URL changes according to the GET. I understand that jQuery automatically accesses a GET request if I do not mean using type: "POST"
, but that is what I consider. Any help would be appreciated.
<script> function addadomain(){ $.ajax({ type: "POST", url: "domains.php", data: $("#domainform form").serializeArray(), success: function() { $("#domainlist").load("domains.php #domainlist"); $.ajaxSetup({ cache: false }); } }); return false; }; </script> <a id="displayText" href="#" onclick="toggle();" >Add Domains</a> <div id="toggleText" style="display: none"> <form name="adddomain" id="domainform" autocomplete="on"> <input type="hidden" name="userid" id="userid" value="<?PHP echo $loggedInUser->user_id; ?>" /> Domain: <input type="text" name="domain" id="domain" required="required" /><br /> Keyword: <input type="text" name="keyword" id="keyword" required="required" /><br /> Facebook Url: <input type="text" name="facebook" id="facebook" /><br /> Twitter Url: <input type="text" name="twitter" id="twitter" /><br /> Analytics ID#: <input type="text" name="analytics" id="analytics" /><br /> Blogspot Url: <input type="text" name="blogspot" id="blogspot" /><br /> <input type="submit" onclick="addadomain()" id="submit" value="submit" /> </form> </div>
source share