954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

want to send 3 text box values to server side method jquery ajax

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); 
    } 
});
amby
Light Poster
30 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

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()}
}
scrappedcola
Posting Whiz in Training
227 posts since Dec 2009
Reputation Points: 27
Solved Threads: 45
 

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.

amby
Light Poster
30 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: