Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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.
 
                 $.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 27-Feb-13 0:08am
dilzz1.2K
Comments
Dec90 at 27-Feb-13 5:19am
   
you have included your JQUERY external script file haven't you? what's the error you get?
dilzz at 27-Feb-13 5:33am
   
I have included the file... and didn't get any error.. it's not working....
Vyacheslav Voronenko at 27-Feb-13 9:13am
   
have you tried to debug, use some http inspector?
Sebastiaan Meijerink at 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 at 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 at 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
0 OriginalGriff 428
1 Maciej Los 249
2 BillWoodruff 199
3 /\jmot 180
4 Suraj Sahoo | Coding Passion 150
0 OriginalGriff 8,484
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,159
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2014
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