tags:

views:

33

answers:

3

hi, im using jquery in asp.net, if i try to use $.ajax functionality, i got this

  1. if i use it in a separate page it works..
  2. when i put it in an ascx and put the ascx out of <form runat="server" >... tags it works
  3. if i put it between <form> tags , jquery works but it doesnt fire $.ajax event
+1  A: 

In my experience most jQuery code should go in $(document).ready(), this is so that the DOM has loaded and the content is there, have you tried that? There is some good info on that here.

If that dosen't work, maybe post some code you are using?

HTH

DannyLane
A: 

can you paste some code so we can have a look?

Dkong
A: 

hi, ive solved it. the problem was with asp .net master pages, there are many ways of sending a post-get request from jquery in ajax, but it seems only some of them work in asp .net, ive posted the code for a chat control in c# in http://code.google.com/p/micachat/

an example that works for get request $.ajax({ beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Content-Type", "application/json"); }, type: "GET", url: "./chatControl/processmessage.aspx?idportal=<%=Request["idportal"] %>", data: "message=" + $('#message').val() + "&name=" + $('#name').val() + "", dataType: "text", success: function(msg){ $("#myDiv").text( "Data Received: " + msg ); } }); // end of ajax