2012-04-23 2 views
2

Я пытаюсь вызвать веб-сервис http://www.w3schools.com/webservices/tempconvert.asmx с помощью JQuery AJAX.JQuery не удается вызвать webservice

function AppendListItems() { 
      var webMethod = "http://www.w3schools.com/webservices/tempconvert.asmx/CelsiusToFahrenheit"; 
      jQuery.support.cors = true; 
      $.ajax({ 
       type: "POST", 
       contentType: "application/json; charset=utf-8", 
       dataType: "json", 
       url: webMethod, 
       data: { Celsius: "10" }, 
       success: function (msg) { 

        $("#lstPhoneNames").append("<li>" + msg.d + "</li>"); 
       }, 
       error: function (ex, a, b) { 
        alert(b); 
       } 
      }); 

     }; 

, но вызов не возвращает журнал ошибок:

<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1> 

      <h2> <i>Runtime Error</i> </h2></span> 

      <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "> 

      <b> Description: </b>An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 
      <br><br> 

      <b>Details:</b> To enable the details of this specific error message to be viewable on remote machines, please create a &lt;customErrors&gt; tag within a &quot;web.config&quot; configuration file located in the root directory of the current web application. This &lt;customErrors&gt; tag should then have its &quot;mode&quot; attribute set to &quot;Off&quot;.<br><br> 

      <table width=100% bgcolor="#ffffcc"> 
       <tr> 
        <td> 
         <code><pre> 

&lt;!-- Web.Config Configuration File --&gt; 

&lt;configuration&gt; 
    &lt;system.web&gt; 
     &lt;customErrors mode=&quot;Off&quot;/&gt; 
    &lt;/system.web&gt; 
&lt;/configuration&gt;</pre></code> 

        </td> 
       </tr> 
      </table> 

      <br> 

      <b>Notes:</b> The current error page you are seeing can be replaced by a custom error page by modifying the &quot;defaultRedirect&quot; attribute of the application&#39;s &lt;customErrors&gt; configuration tag to point to a custom error page URL.<br><br> 

      <table width=100% bgcolor="#ffffcc"> 
       <tr> 
        <td> 
         <code><pre> 

&lt;!-- Web.Config Configuration File --&gt; 

&lt;configuration&gt; 
    &lt;system.web&gt; 
     &lt;customErrors mode=&quot;RemoteOnly&quot; defaultRedirect=&quot;mycustompage.htm&quot;/&gt; 
    &lt;/system.web&gt; 
&lt;/configuration&gt;</pre></code> 

        </td> 
       </tr> 
      </table> 

      <br> 

    </body> 

Am я вызов службы неправильный путь?

+0

Вы тестируете это в браузере или на эмуляторе или на реальном устройстве? – Th0rndike

+0

yup Я тестирую это на IE, браузерах Chrome – Tuscan

+0

Я никогда не мог тестировать вызовы ajax из браузеров при использовании jquery-mobile, так или иначе они работают только в эмуляторе или реальном устройстве. Я хотел бы знать, знает ли кто, что пошло не так. – Th0rndike

ответ

0

попробуйте добавить в документе готового:

jQuery.support.cors = true; 
+0

спасибо, но не работает – Tuscan

0

проверить, что фактический запрос отправляется на сервер с помощью какого-то инструмента, как Fiddler. Вы можете найти различия в том, что вы отправляете, в отношении того, что на самом деле требуется

0
+0

Возвращенный результат: Сервер не смог обработать запрос. --- > Данные на корневом уровне недействительны. – Tuscan

Смежные вопросы