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 html is simple. They are 7 normal and current fields.
What I am trying is that when sending the data to a page, it resends it again. That is, page 1 sends data to page 2, and page 2 puts it in a database and automatically sends it to page 3
It gives me the following error.
Uncaught TypeError: Cannot read property 'post' of undefined at function at window.onload
Does anyone have an idea why?
That same code I used before, just modify one or two little things. I don't know what this is though "$("#principal").html(data);"
. I put that ID name to the form just in case, maybe it's wrong.
Thank you for your trouble.
You are missing the parentheses of the function.
As for the part:
It is adding to an ID called "main" the content of "data".
When the function gets executed jQuery hasn't been loaded, that's why it tells you "Cannot read property 'post' of undefined". Perhaps in one of the edits you have made you have mistakenly deleted the jQuery loading tag.
As for the second part, with the following code:
what it would do is replace the form with the received data, which is probably not what you want.