Reputation: 319
I need to put to parameter in DATA , how can I do this ?
I try that , but that did'nt work :
data: dataString + form_data ,
My complete code:
$(".edit_tr").click(function()
{
var ID=$(this).attr('id');
$("#first_"+ID).hide();
$("#last_"+ID).hide();
$("#first_input_"+ID).show();
$("#last_input_"+ID).show();
}).change(function()
{
var ID=$(this).attr('id');
var first=$("#first_input_"+ID).val();
var last=$("#last_input_"+ID).val();
var dataString = 'id='+ ID +'&firstname='+first+'&lastname='+last;
$("#first_"+ID).html('<img src="load.gif" />');
if(first.length && last.length>0)
{
var form_data = {
ci_csrf_token: $.cookie("ci_csrf_token"),
}
$.ajax({
type: "POST",
url:'http://' + document.domain + '/school/teachers/editscore/',
//data: dataString,
data: form_data,
//cache: false,
success: function(html)
{
$("#first_"+ID).html(first);
$("#last_"+ID).html(last);
}
});
Upvotes: 2
Views: 2045
Reputation: 69905
You pass data as a json object
var form_data = '&ci_csrf_token='+ $.cookie("ci_csrf_token");
};
$.ajax({
type: "POST",
url:'http://' + document.domain + '/school/teachers/editscore/',
//data: dataString,
data: dataString + form_data,
processData: false,
//cache: false,
success: function(html)
{
$("#first_"+ID).html(first);
$("#last_"+ID).html(last);
}
});
Upvotes: 2
Reputation: 24052
You're trying to concatenate a string and a Json literal and store it in a parameter that accepts Json.
Instead, if you want to pass two different things to the server, store it as two different properties in the Json:
var form_data = {
ci_csrf_token: $.cookie("ci_csrf_token"),
string: "dataString"
};
$.ajax({
type: "POST",
url:'http://' + document.domain + '/school/teachers/editscore/',
data: form_data,
success: function(html)
{
$("#first_"+ID).html(first);
$("#last_"+ID).html(last);
} });
You can always then just perform the concatenation on the server side of your application once you have each property.
Upvotes: 1
Reputation: 37464
data: dataString + form_data ,
should work, i was struggling to fully understand your question.
Upvotes: 0