Uncaught TypeError: Can not read property 'post' of undefined

0

My code so far:

<p><script language="javascript">
function funcion(){
    var a ="field_1";
    var b ="field_2";
    var c ="field_3";
    var d ="field_4";
    var e ="field_5";
    var f ="field_6";
    var g ="field_7";
    var aa = document.getElementById(a).value;
    var bb = document.getElementById(b).value;
    var cc = document.getElementById(c).value;
    var dd = document.getElementById(d).value;
    var ee = document.getElementById(e).value;
    var ff = document.getElementById(f).value;
    var gg = document.getElementById(g).value;
    $.post("Aqui va mi URL", { dni: aa, proc: bb, firma: cc, exp: dd, us: ee, "11": ff, "10": gg }, <br>function(data){
    $("#principal").html(data);
    });
}
window.onload = funcion;

So far the JavaScript and the HTML are simple. There are 7 normal and ordinary fields.

What I'm trying to do is that when you send the data to a page, it sends it back again. That is, page 1 sends data to page 2, and page 2 enters a database and automatically sends them to page 3

I get the following error.

  

Uncaught TypeError: Can not read property 'post' of undefined       at work       at window.onload

Does anyone have any idea why?

That same code I used before, just modify one or two things. Although I do not know what this is "$("#principal").html(data);" . I put the form of that ID name just in case, maybe it's wrong.

Thanks for the inconvenience.

    
asked by David 30.08.2017 в 11:34
source

2 answers

1

When the function comes to run jQuery has not been loaded, so it says "Can not read property 'post' of undefined." Perhaps in one of the editions you have made, you have mistakenly deleted the jQuery load tag.

Regarding the second part, with the following code:

$("#principal").html(data);

What I would do is replace the form with the data received, which probably is not what you want.

    
answered by 30.08.2017 / 12:06
source
1

You are missing the parentheses of the function.

window.onload = funcion();

Regarding the part of:

$("#principal").html(data);

You are adding the "data" content to an ID called "main".

    
answered by 30.08.2017 в 11:49