Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Experts,

I have a doubt in Asp.net. In my Asp.net project i have used a ajax json code for passing values to webservice through webmethod.

When i write the ajax code in the webform, then it is working fine. And when i moved this code in a javascript file, then it is not working......

Can someone please help me to solve this issue.... Here is the below ajax code that am used.

JavaScript
$.ajax(
  {
      type: "POST",
      url: "../General_Services.asmx/HelloWorld",
      dataType: "json",
      data: JSON.stringify({ "Sub_Item_ID": "abc" }),
      contentType: "application/json; charset=utf-8",
      success: function (json) {
          alert(json.d);
      }

  });



Thanks in Advance,

Dileep
Posted
Comments
Dec90 27-Feb-13 5:19am    
you have included your JQUERY external script file haven't you? what's the error you get?
dilzz 27-Feb-13 5:33am    
I have included the file... and didn't get any error.. it's not working....
Vyacheslav Voronenko 27-Feb-13 9:13am    
have you tried to debug, use some http inspector?
Sebastiaan Meijerink 27-Feb-13 18:01pm    
Is the script file at the bottom of you're body?
Did you try to wrap it in;
$(document).ready(function() {
//you're code here
});
dilzz 1-Mar-13 2:44am    
@Sebastiaan Meijerink Yes this script file is at the bottom of the body...

And this code is put in the

$(document).ready(function() {
//you're code here
});

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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