Hi, I want to send three text box values to server using jquery ajax. problem is that, i dont know the exact syntax to send three data. When i try sending one data(also change no.of parameters to one at server side method), its going good but when i try to send three text box values, its giving jquery error:"Internal server error". I think I am not sending data in correct way. please somebody tell me how to do that. Example below contains only two sending data, because i was trying to send 2 data first.

Below is the code:

function testCAll() { 
$.ajax({ 
    type: "POST", 
    url: "dbTest1.aspx/SendMessage", 
    data: "{'name': '" + $('#Eid').val() + "', 'phone': '" + $('#phn').val() + "'}", 
    //data: "{'phone': '" + $('#CustomerPhone').val() + "'}", 
    //data: "{'color': '" + $('#ColorId').val() + "'}", 
    contentType: "application/json; charset=utf-8", 
    dataType: "json", 
    success: function(result) { 
        resultData = eval("(" + result.d + ")"); 
        $("#rawResponse").html(concatObject(resultData)); 
    }, 
    error: function(result) { 
        alert("jQuery Error:" + result.statusText); 
    } 
});

Recommended Answers

When passing data using ajax you only pass one data element and use a json object to pass more than one value.

data: {
    data1:{'name':$('#Eid').val(),'phone':$('#phn').val()},
    data2:{'phone':$('#CustomerPhone').val()},
    data3:{'color':$('#ColorId').val()}
}
Jump to Post

All 2 Replies

When passing data using ajax you only pass one data element and use a json object to pass more than one value.

data: {
    data1:{'name':$('#Eid').val(),'phone':$('#phn').val()},
    data2:{'phone':$('#CustomerPhone').val()},
    data3:{'color':$('#ColorId').val()}
}

thanks, problem solved using below string:
data: "{name: '" + $('#Eid').val() + "', phone: '" + $('#phn').val() + "'}",

i have found out that problem is on my server side.

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.