首页 \ 问答 \ 无法在浏览器中手动访问ASMX Web服务,但它可以使用jQuery(Can't access ASMX web service manually in browser but it works using jQuery)

无法在浏览器中手动访问ASMX Web服务,但它可以使用jQuery(Can't access ASMX web service manually in browser but it works using jQuery)

我是JQuery和Web Services的新手。 我的问题是(在下面的代码中),为什么url:“WebService1.asmx / WebMethod”通过这个JQuery代码工作,但如果我直接在浏览器中输入该URL,它说无法找到路径? 我必须在浏览器中手动单击服务的“调用”按钮才能调用该方法,然后导航到WebService1.asmx / WebMethod。

 $(document).ready(function () {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "WebService1.asmx/WebMethod",
            data: "{}",
            dataType: "json",
            success: function (msg) {
                alert(msg.d);
            },
            error: function (errormessage) {
                alert("got an error");
            }
        });
    });

I'm new to JQuery and Web Services. My question is (in the following code), why does url: "WebService1.asmx/WebMethod" work through this JQuery code but if I type that URL directly in my browser, it says the path cannot be found? I have to manually click on the "Invoke" button for the service in the browser in order to call the method and then it navigates to WebService1.asmx/WebMethod.

 $(document).ready(function () {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "WebService1.asmx/WebMethod",
            data: "{}",
            dataType: "json",
            success: function (msg) {
                alert(msg.d);
            },
            error: function (errormessage) {
                alert("got an error");
            }
        });
    });

原文:
更新时间:2021-09-20 10:09

最满意答案

let des = data.description as NSString
            let dataAsString = des.substringWithRange(NSMakeRange(1, data.description.characters.count-2))
            var value = UInt8(0)
            data.getBytes(&value, range: NSMakeRange(0, dataAsString.characters.count/2))
print(value)

let des = data.description as NSString
            let dataAsString = des.substringWithRange(NSMakeRange(1, data.description.characters.count-2))
            var value = UInt8(0)
            data.getBytes(&value, range: NSMakeRange(0, dataAsString.characters.count/2))
print(value)

相关问答

更多
  • 您无法存档这样的UIImage实例。 您必须首先创建外部表示,如PNG或JPG。 你可以使用例如UIImagePNGRepresentation()函数来做到这一点。 它将返回一个NSData实例,其中包含PNG格式的压缩图像。 该NSData实例可以与NSArchiving一起使用。 You cannot archive UIImage instances like that. You will have to create an external representation first, like P ...
  • 当您要以这种方式将变量的指针作为参数发送时,变量需要是可变的(即,使用var声明),因为接收函数或方法将能够直接修改变量。 你想要的代码是: var random = NSInteger(arc4random_uniform(99) + 1) //(1-100) let data = NSData(bytes: &random, length: 3) 您可以在使用Swift with Cocoa和Objective-C:与C API交互时阅读更多关于使用UnsafePointer 。 When ...
  • 问题是您在onCreate中注册接收器,它应该在onResume 。 这是发生的事情: 您的活动开始:接收者已注册; 您移动到另一个屏幕或屏幕被锁定:接收器未注册; 你回到活动:接收器仍未注册; 移动到另一个屏幕:您尝试取消注册接收器但它没有注册。 所以要解决这个问题,尝试将接收者注册移动到onResume如果可以的话。 如果你不能只在try/catch语句中包装该调用: @Override protected void onPause() { // TODO Auto-generated meth ...
  • NSDictionary - > NSData: NSData *myData = [NSKeyedArchiver archivedDataWithRootObject:myDictionary]; NSData - > NSDictionary: NSDictionary *myDictionary = (NSDictionary*) [NSKeyedUnarchiver unarchiveObjectWithData:myData]; NSDictionary -> NSData: NSData ...
  • 请注意,您的manufacturerData变量的类型应该是NSData ,而不是id 。 查看NSData的文档。 length属性的返回类型是什么? 现在看看你正在使用的类型。 看到不同? 始终使用正确的数据类型。 您也可以使用subdataWithRange:方法而不是使用字节。 NSData *manufacturerData = [advertisementData objectForKey:CBAdvertisementDataManufacturerDataKey]; if (manufact ...
  • 尝试使用单字节值的数组创建数据。 const uint8_t bytes[] = {0xDE}; NSData *data = [NSData dataWithBytes:bytes length:sizeof(bytes)]; 这是创建任意常量数据的有用方法。 对于更多字节, const uint8_t bytes[] = {0x01,0x02,0x03,0x04,0x05}; NSData *data = [NSData dataWithBytes:bytes length:sizeof(bytes) ...
  • 这与NSString(十六进制)到字节非常相似。 如果删除多余的标点符号,那么答案将对您有用。 This is extremely similar to NSString (hex) to bytes. The answer there will work for you if you remove the excess punctuation.
  • 没有。 + (id)dataWithBytes:(const void *)bytes length:(NSUInteger)length 这个方法只需要2个参数:void指向内存中的字节流的指针,以及从这个字节流中获取NSData对象的数量。 与其他任何方法一样,这种方法没有线索,也不在意,你如何得到这个字节流,当然不知道UTF8String的任何内容,它只关心数据类型,它们与方法签名相匹配。 Matthias解释说,关于如何确定字符串长度的想法也是错误的。 使用strlen C函数。 此函数检查字符串 ...
  • 你可以这样做,只要你有一组预定义的消息可能值: import Foundation let data = NSData(bytes: [0xa2, 0x12] as [UInt8], length: 2) enum Data: UInt16 { case Init = 0x12a2 case Opened = 0x12a1 case AlreadyOpened = 0x13a1 case Finished = 0x12a3 } func convert(data: NSData) ...
  • let des = data.description as NSString let dataAsString = des.substringWithRange(NSMakeRange(1, data.description.characters.count-2)) var value = UInt8(0) data.getBytes(&value, range: NSMakeRange(0, dataAsString.characte ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。