Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Call Web Service with AJAX

Call Web Service with AJAX

Scheduled Pinned Locked Moved Web Development
xmlhelpcsharphtmlvisual-studio
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_15196138
    wrote on last edited by
    #1

    Hello I have web service solution in Visual Studio with one parameter :

    Public Function CheckPalletInLocation(location As String) As String

        Dim ScaleConnnection As New SqlClient.SqlConnection("MYCONNEXION")
        Dim ScaleCommand As New SqlClient.SqlCommand
        ScaleCommand.Connection = ScaleConnnection
        ScaleConnnection.Open()
        ScaleCommand.CommandText = "SELECT DISTINCT LOGISTICS\_UNIT FROM LOCATION\_INVENTORY WHERE LOCATION = '" & 
        location & "'"
        Return ScaleCommand.ExecuteScalar()
        ScaleConnnection.Close()
    
        'Return "True"
    End Function
    

    When I launch solution, webservice works. It return value. Now I want to call it in HTML page with ajax code :

        TEST WEB SERVICE
    	
    
    PAGE
    
    
    function Click\_BB()
    {
    	$.ajax({
    	  type: 'post',
    	  url: 'https://localhost:44341/WebService1.asmx?op=CheckPalletInLocation',
    	  contentType: "application/xml",
    	  data: { location: '110-01-03-10' },
    	  success: function (d) 
    		  {
    			alert(d);
    		  },
    	  failure: function (response) 
    		  {
    			debugger;
    			alert(response.d);
    		  }
    	});
    }
    

    I always have this error in the response page :

    soap:ReceiverSystem.Web.Services.Protocols.SoapException: Le serveur n'a pas pu traiter la demande. ---> System.Xml.XmlException: Données non valides au niveau racine. Ligne 1, position 1.

    I transale : server cannot process. Invalid data root, line 1 position 1

    Can someone help please ?

    Thanks

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups