Search code examples
jqueryjquery-post

jquery .post() is sent as .get()


I'll be short I have this function

$("#JqPostForm").submit(function(e){    
    e.preventDefault();  
    $("#despliegaresultados").empty();
    $("#paginacion").empty();
    $.post("php/prueba.php", $('#JqPostForm').serialize(),

    function(data)
    {
        $.each(data, function(i, item)
        {
            total= item.total;
            datos = item.datos;
        });

        //is doing something here 

    });
}, "json");

with this html

<html>
.....
   <form>
       <input type="text" name="nombre">
       <input type="submit"> 
   </form>
......
</html>

and well it works fine, send and receive post data with json format, my problem is that when i try to save the form in a different html and then retrieve it through a button or something, my call is done with "GET" params and i have no idea why.

I have read the .load() from jquery doc, also many post from this site but i don't seem to find any information, i also want to mention that i know .load is by default get, i send some parameters to make it post, this is how i get the form from an external archive

$('#target').load('php/searchForm.html',{algo:'algo'});

then my form is loaded now on my html, but when i submit it my call changes to "GET". pd. excuse my english i'm not american neither english thanks.


Solution

  • after so much looking for i came with this solution jQuery load relaoding content in div via form submit in div

    finally the solution, my problem was solved this way, i moved both files, "index" and "externalForm" to the same directory, both of them on header had and voila i could load an external form and then use it