0

I would like to post the variable var projectid=data.projectid, the same as i did with:

 url: "rapportage/rapport_detail?idKlant=" + klant, 

the ajax call look like this:

$.ajax({ type: "POST", url: "rapportage/rapport_detail?idKlant=" + klant, dataType: 'json', error: function(){ alert("Onvoldoende gegevens beschikbaar om rapportage to genereren."); }, success: function(data){ // Plaats data op de juiste plek in de tabel var projectid=data.projectid, titel=data.titel, projecttype =data.projecttype, projectleider =data.projectleider, projecttype =data.projecttype, statusproject =data.statusproject, startproject =data.startproject, deadlineproject =data.deadlineproject, omzetproject =data.omzetproject, kostenproject =data.kostenproject, margeproject =data.margeproject, totaalurenproject =data.totaalurenproject, totaalminutenproject =data.totaalminutenproject, urenkostenproject =data.urenkostenproject; var str=''; for(var i=0,len=titel.length;i<len;i++){ str+="<tr>"+"<td>" + titel[i] + "</td>"; str+="<td>" + projectleider[i] + "</td>"; str+="<td>" + projecttype[i] + "</td>"; str+="<td>" + statusproject[i] + "</td>"; str+="<td>" + startproject[i] + "</td>"; str+="<td>" + deadlineproject[i] + "</td>"; str+="<td>" + "&#8364;" + omzetproject + "</td>"; str+="<td>" + "&#8364;" + kostenproject + "</td>"; str+="<td>" + "&#8364;" + margeproject + "</td>"; str+="<td>" + totaalurenproject + ":" + totaalminutenproject + "</td>"; str+="<td>" + "&#8364;" + urenkostenproject + "</td>"+"</tr>"; } alert(JSON.stringify(data)); $("#details tbody").append(str); } }); 

2 Answers 2

1

You can use this;

$.ajax({ type: "POST", url: "rapportage/rapport_detail?idKlant=" + klant, dataType: 'json', success: function(data) { var projectid=data.projectid; ........ $.ajax({ type: "POST", url: "rapportage/rapport_detail?idKlant=" + klant, data: "projectid=" + projectid, dataType: 'json', success: function(response) { } } ..... 
Sign up to request clarification or add additional context in comments.

6 Comments

this doesnt seem to work because the data:projectid has no value there because its done before the var projectid = data.projectid
I assumed you have already that variable, so you you want too resend it after first ajax success?
yes srry:) thats exactly what i wanted to do. i thought about something like this var projectid=data.projectid; $.post("rapportage/rapport_detail?idProject=" + projectid); console.log(projectid);
See my updated answer, but you do not need to resend that request again. You can do that in first ajax request at the backend already
When i do it like that i get an NULL response but when i log it it has values in it.
|
0

i didn't get what you are asking, but if you want to post a variable by POST then you can

type: "POST", url: "rapportage/rapport_detail", data : {"idKlant" : klan}, 

add this in ajax

1 Comment

@doniyor key can be string, you can try

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.