Click here to Skip to main content
13,055,490 members (52,346 online)
Rate this:
Please Sign up or sign in to vote.
Dear Experts,

I have a doubt in In my 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.

      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) {


Thanks in Advance,

Posted 26-Feb-13 23:08pm
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
Sebastiaan Meijerink 12-Mar-13 18:06pm
Next to a success function you can also specify an error function in $.ajax.
That will give you three parameters and should give you more information.

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

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100