Jquery Ajax Confusion
Last Post 02/03/2016 10:52 PM by pratik shukla. 3 Replies.
Author Messages
wynnjon
Nuke Active Member
Nuke Active Member
Posts:24


--
10/13/2009 4:21 PM  
OK guys-  I'm not sure who else to turn to on this one...

I'm using the following jquery script in a .js file:

$(document).ready(function() {
     $.ajax({
      type: "POST",
      url: "http://localhost/dddev/ddcode.aspx/HelloWorld",
      contentType: "application/json; charset=utf-8",
      data: "{}",
      dataType: "json",
      success: function() {
         alert('worked');
      },
   error: function(){
   alert('failed'); 
   }
    });
  });

When it runs, it always returns failed.  Anyone have any ideas why this would not be working?

I verified that jQuery is working b/c when I run the code:

$(document).ready(function() {
             alert('worked');
      },
});

The page load generates a alert box that says "worked"

But when I attempt to run the code using $.ajax it's not working, it always returns failed.

Any help would be appreciated!!!

Thank you,
Jones
wynnjon
Nuke Active Member
Nuke Active Member
Posts:24


--
10/13/2009 4:30 PM  
Got it!

OK... so my page method wasn't shared...

_
Public Shared Function HelloWorld() As String
Dim strTemp As String = "It worked!"
Return strTemp
End Function
Joseph Craig
DNN MVP
Posts:11667


--
10/14/2009 6:37 PM  
I've also seen recommendations that you not use the $ as that conflicts with something else in DotNetNuke.  Instead, you should spell out "jquery".

Joe Craig, Patapsco Research Group
Complete DNN Support
pratik shukla
Nuke Newbie
Nuke Newbie
Posts:1


--
02/03/2016 10:52 PM  
I guess it is your URL parameter of the ajax function. i am still finding the correct url pattern to call the server side webmethod from jquery. by far i didnt get any success. i tried debugging but my debugger never went on the webmethod of server side.


---