2011-11-18 4 views
0
%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script> 
    <script type="text/javascript"> 
     $(document).ready(function() { 
      debugger; 
      var counter = "test"; 
      WebApplication1.Service1.DoWork(counter, ResultLoadMainGridProductType, ErrorLoadMainGridProductType); 
     }); 
     function ResultLoadMainGridProductType() { 


     } 
     function ErrorLoadMainGridProductType() { 


     } 
    </script> 
    <form id="form1" runat="server">  
    <div> 
    <asp:ScriptManager ID="ScriptManager" runat="server">    
      <Services> 
       <asp:ServiceReference Path="~/Service1.svc" /> 
      </Services> 
     </asp:ScriptManager> 
    </div> 
    </form> 
</body> 
</html> 

코드가 실패합니다. WebApplication1.Service1.DoWork(counter, ResultLoadMainGridProductType, ErrorLoadMainGridProductType); 오류 : Microsoft Jscript : "WebApplication1"구현 오류가 확실하지 않습니다. WebApplication1 - 네임 스페이스 ... 자바 스크립트 코드에서 정의되지 않은 것을 볼 수 있습니다. 어떻게 만들 수 있을까요 ??asp.net web에서 javascript에 네임 스페이스를 가져 오는 방법은 무엇입니까?

+0

'WebApplication1.Service1.DoWork'는 서버 측 메소드입니까? –

답변

0

$(document).ready(function() { 
    debugger; 
    var counter = "test"; 
    var service1 = new WebApplication1.Service1(); 
    service1.DoWork(counter, ResultLoadMainGridProductType, ErrorLoadMainGridProductType); 
}); 

는 또한 자바 스크립트 파일 jsdebug이로드 된 스크립트에서이 있는지 확인하려면 확인하십시오.

+0

동일한 오류가 발생했습니다 : var service1 = new WebApplication1.Service1() –

+0

jsdebug가 있습니까? WCF 서비스로 직접 이동하면 어떻게됩니까? 예 : http : // localhost : (portnumber) /Service1.svc? –

+0

하지만 jsdebug 실제로로드되지 않습니다 :) web.config 오류))) –

관련 문제