Wann willst du dann den input auslesen?
Ankündigung
Einklappen
Keine Ankündigung bisher.
html formular daten an JS weitergeben ohne seite verlassen
Einklappen
Neue Werbung 2019
Einklappen
X
-
Zitat von Karle Beitrag anzeigenIch wollte das Input feld auslesen und cen Wert des Feldes in die AJAX als Parameter mitgeben. Ausgangspunkt war der Code
HTML-Code:var value; $( "input" ) .keyup(function() { value = $( this ).val(); $( "p" ).text( value ); }) .keyup();
Kommentar
-
Hier nochmal das ganze:
HTML-Code:$(document).ready(function() { var value; $( "input" ) .keyup(function() { value = $( this ).val(); $( "p" ).text( value ); }) .keyup(); //$( "input" ) --oder so da die events sonst nicht zusammenpassen //value = $( this ).val(); $.ajax({ url : "http://localhost:8002/Prodmde/api/data.php", type : "GET", data: { StartDate: value} , //mzi übergabe ab hier geht // code ab hier für das Problem uninteressant success : function(data){ console.log(data); var production = { tucan : [], lion : [], res : [], res2: [], RunNr:[] }; var len = data.length; for (var i = 0; i < len; i++) { if ((data[i].MachNo == 1004989 ) & (data[i].RunNr < 900 ) & (data[i].RunNr > 1 ) ) { production.tucan.push(data[i].BrushCount); //production.RunNr.push(data[i].RunNr); } else if (data[i].MachNo == 1004993) { production.lion.push(data[i].BrushCount-5000); production.RunNr.push(data[i].RunNr); } production.res.push(data[i].BrushCount); production.res2.push(data[i].BrushCount-8000); } //get canvas var ctx = $("#line-chartcanvas"); var data = { labels : production.RunNr , // ["Mo", "Di", "Mi", "Do", "Fr"] datasets : [ { label : "TeamA Z.Tucan ", //TeamA score data : production.tucan, backgroundColor : "blue", borderColor : "lightblue", fillColor : "lightblue", fill : false, lineTension : 0.5, pointRadius : 3, pointHoverRadius : 10 }, { label : "TeamB Z.Lion ", //TeamB score data : production.lion, backgroundColor : "green", borderColor : "lightgreen", fillColor : "lightgreen", fill : false, lineTension : 0.5, pointRadius : 3, pointHoverRadius : 10 }, { label : "res ", //TeamB score data : production.res, backgroundColor : "red", borderColor : "red", fillColor : "red", fill : false, lineTension : 0.5, pointRadius : 3, pointHoverRadius : 10 }, { label : "res2 ", //TeamB score data : production.res2, backgroundColor : "black", borderColor : "black", fillColor : "black", fill : false, lineTension : 0.5, pointRadius : 3, pointHoverRadius : 10 } ] }; var options = { title : { display : true, position : "top", text : "Production Plant A", //Line Graph fontSize : 18, fontColor : "#111" }, legend : { display : true, position : "bottom" }, animation: { // mzi erweiterung duration: 8000, // general animation time }, hover: { animationDuration: 3000, // duration of animations when hovering an item } }; var chart = new Chart( ctx, { type : "line", data : data, options : options } ); }, error : function(data) { console.log(data); } }); });
Kommentar
-
Vielen Dank!!!
Variable kommt im console log an !!!!! mit beiden Varianten, auch der auskommentierten.
HTML-Code:$(document).ready(function() { //var StartDate = document.getElementById('StartDate').value; var StartDate=$('#StartDate').val(); console.log(StartDate); $.ajax({ url : "http://localhost:8002/Prodmde/api/data.php", type : "GET", data: { StartDate: StartDate} , success : function(data){ //usw usv
data: { StartDate: 'StartDate'} ,
data: { StartDate: "StartDate"} ,
kann mir hier noch jemand nen Tipp geben?
Vielen Dank!
Kommentar
-
HTML-Code:type : "GET",
PHP-Code:@$_POST['StartDate'];
Was macht das @-Zeichen dort?
Anstatt dass du Dir ein Tutorial gesucht hättest und dies sauber durchgearbeitet hättest versuchst du irgendwas ohne das wohl auch nur im Ansatz zu verstehen (so machts zumindest den Anschein). Weit wirst du damit nicht kommen.
Kommentar
-
Ich hatte im verlauf des ganzen spasses mal eine Fehlermeldung nicht mehr sicher welche und da habe ich in nem Tutorial gelesen das das helfen soll.
edit: Ich meine das war das:
http://php.net/manual/de/language.op...rorcontrol.php
Könnt ihr ein programmier Tool emphehler ich hacke hier mit notepad++ rum...
Kommentar
-
Zitat von Karle Beitrag anzeigenIch hatte im verlauf des ganzen spasses mal eine Fehlermeldung nicht mehr sicher welche und da habe ich in nem Tutorial gelesen das das helfen soll.
Kommentar
Kommentar