Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Ajax
Hi,
 
I deployed the service in windows server 2008 R2
 
i tried to update a record in db using the service. i have used 'put' method for update.
 
i called the service by ajax as follows -
<script type="text/javascript">
 
        function test() {
        ;
 
            var AssetUpdate = {
              
                logInInfo: { UserName: 'mark.ritter@e-isg.com', Password: 'password' },
                asset: {
                    AssetName: 'a',
                    Barcode: '1',
                    AssetDescription: '1',
                    AssetIDInternal: 'D2907B1D-8AE9-49D8-A905-65DD356858B2',
                    PeopleIDInternal: 'ED98D0E6-4AB4-41D4-9EC2-5A289D33595B',
                    LocationIDInternal: '48A986EA-00BE-46FC-A377-C19B63DA540C',
                    AssetCategoryIDInternal: '6E41C53F-BA24-4A8B-9892-79AF133549C7',
                    SiteIDInternal: '8A63BD8B-6B1A-4C91-96E5-3DE44FF07BC0',
                    AssetUsageID: '1',
                    AssetConditionID: '1',
                    AssetStatus: '12',
                    AssetSerialNo: '123',
                    Price: '12',
                    PurchaseDate: '01/01/2012',
                    PurchaseOrderNo: '55',
                    Quantity: '456',
                    Vendor: '67',
                    IsActive: 'True',
                    AuditDate: '01/01/2012',
                    AuditStatus: '4353',
                    Asset_UID: '1',
                    DataGatherID: '34',
                    ActualCost: '345',
                    FederalCost: '435',
                    MatchCost: '324',
                    Mfg: 'TEST',
                    Model: '1',
                    POLine: '1',
                    POStatus: '1',
                    ScannerDeviceCode: '1',
                    DateModified: '01/01/2012'
                }, AssetIDInternal: '5afb3768-db2f-42d1-8c47-3da008c6cdee'
            };
 
            try {
                $.ajax({
                     url: "http://172.16.0.110:80/vamsyncservices/api/Asset/UpdateAsset",
                  
                    type: "PUT",
                    dataType: 'json',
 
                   data: AssetUpdate,
 
                    success: function () {
                        alert("Done");
                        alert('Asset Updated successfully.');
                    },
                    Failure: function () {
                        alert("Fails");
                    }
 

                });
            }
            catch (e) {
                alert(e);
            }
        }     
 
    </script>
******************************************************************************
Config file :
 <system.webServer>
    <modules>
       <remove name="WebDAVModule"/>
    </modules>
    
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type" />
        <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
      </customHeaders>
    </httpProtocol>
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
 
**********************************************************************************
 
When i run the script i got an error as follows
"XMLHttpRequest cannot load http://rest.e-isg.com/vamsyncservices/api/Asset/UpdateAsset. Origin http://localhost:52265 is not allowed by Access-Control-Allow-Origin."
 
Help ?
Posted 9-Nov-12 3:56am
Edited 9-Nov-12 4:52am
(no name)33.1K
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Mathew Soji 274
1 BillWoodruff 270
2 Afzaal Ahmad Zeeshan 244
3 Sergey Alexandrovich Kryukov 240
4 Raul Iloc 160
0 OriginalGriff 6,219
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,103
3 Manas Bhardwaj 4,549
4 Maciej Los 3,845


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100