Ciao a tutti,
sto provando un esempio per chiamare webmethod con Ajax e JQuery (questo è il link http://encosia.com/using-jquery-to-d...-page-methods/ ).
L'applicazione su cui sto facendo il test usa Framework 3.5 e quando lancio l'esempio, mi da un errore dovuto a questo codice nel web.config
Come devo cambiarlo per farlo funzionare?codice:<system.web.extensions> <scripting> <scriptResourceHandler enableCompression="true" enableCaching="true" /> </scripting> </system.web.extensions>
La pagina è la seguente, che non riesco a far funzionare:
Grazie in anticipo!codice:<%@ Page Language="VB" AutoEventWireup="true"%> <%@ Import Namespace="System.Web.Services" %> <%@ Import Namespace="System.Web.Script.Services" %> <script runat ="server" > <WebMethod()> _ Public Function HelloWorld(ByVal a As Integer) As String Return "Hello: " & DateTime.Now.Millisecond End Function </script> <!DOCTYPE html> <html> <head> <title>Calling page methods with jQuery</title> <style type="text/css"> #Result { cursor: pointer; } </style> </head> <body> <div id="Result">Click here for the time.</div> <script type="text/javascript" src="../Script/jquery-1.7.1.min.js"></script> <script type ="text/javascript"> $('#Result').click(function() { $.ajax({ type: "POST", url: "Default.aspx/HelloWorld", data: "{}", contentType: "application/json", dataType: "json", success: function(msg) { // Replace the div's content with the page method's return. $("#Result").text(msg.d); } }); }); </script> </body> </html>

Rispondi quotando