Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I managed to call c# methods through AJAX, but now I have a simple doubt:

On my .js I have:

function criarNota() {

    var note_id = jQuery.fn.stickyNotes.createNote();
    alert("isto: "+note_id);
    PageMethods.criarNota(note_id,function(result) { // é enviado o ID da nota criada
                alert(result);
            });
            }



I send the note_id var to server.

C#
[System.Web.Services.WebMethod]
   public static string criarNota(int note_id)
   {
       try
       {
          // receives note_id, execute sql statement and I get:

           // string text
           // int id

         

           return ...........;
       }


How can I return that text and id var and how to receive it my js function?
Posted

1 solution

 
Share this answer
 
Comments
Maxdd 7 22-Dec-10 21:15pm    
I know how to do that, I already do it, but what I want is to return two variables (c#) and received them with JS. I can do it with one, my problem is do it with more than one.
Maxdd 7 22-Dec-10 21:17pm    
i.e.; I want to return [text,id] so I can receive at Js like function carregarNotas(result1,result2) {
Maxdd 7 22-Dec-10 21:30pm    
This way I get nulls again:

function verNumNotas() {

PageMethods.verNumNotas(carregarNotas);
}

function carregarNotas(result) {

var texto = result[0];
var num = result[1];

alert("istooo:" + num + "e isto "+texto);
loadNotes(num);
}
Maxdd 7 22-Dec-10 21:39pm    
I rewrited my code and its working now.
[no name] 22-Dec-10 21:52pm    
If knew it then why were you asking?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900