Tag: httprequest

使用`GET`请求表单的客户端,即使`POST`被定义。 是javascript iframe的原因?

我的网站上有两个后续表格,使用POST方法。 我的网站first.php的第一页包含以下代码: a.php只能通过此POST请求访问(否则用户将获取方法不允许405错误) 提交后,此表单将打开带有AJAX模式窗口的a.php 。 a.php包含另一种forms: 当用户单击第二种forms的提交时,它将打开b.php ,也可以仅通过POST请求访问(否则 – 405错误)。 我可以在这些表单之间考虑的唯一区别是第二个包含跟踪js类(打开iframe)。 这是js代码: $(document).ready(function() { $(“.tracking”).click(function(){ var iframe = document.createElement(‘iframe’); iframe.style.width = ‘0px’; iframe.style.height = ‘0px’; iframe.style.display = ‘block’; document.body.appendChild(iframe); iframe.src = ‘/track.htm’; }); 这样做是为了使用从track.htm第三方脚本来跟踪转换 我注意到我的iPad访问量约占5%。 他们使用POST请求正确打开a.php ,但是当他们继续并继续打开b.php ,大约5%发出GET请求而不是所需的POST请求,导致他们得到405错误并离开网站。 我知道这些是真正的人类用户,因为我可以看到他们中的一些人多次尝试打开b.php并继续得到这些405错误。 这可能是因为他们的设备同时使用GET请求获取track.htm吗? 这是一些小故障? 怎么解决这个问题? 编辑4.4.2015: 由于有可能触发跟踪脚本导致此问题,我想知道是否有另一个火来触发它(或跟踪adwords转换),而不会导致这些iPad用户也对表单使用“GET”请求。 编辑10.4.2015 : 这是ajax类的jquery代码,它同时影响first.php和a.php ,因为first.php是父框架: $(document).ready(function() { $(“.ajax”).click(function(t) { t.preventDefault(); var e […]

jQuery.ajax()记录HTTP请求

我有一个发送HTTP POST请求的函数,我想记录它以进行调试。 这是function: function serverRequest(URL, DATA, callback) { $.ajax({ url: URL, type: “POST”, dataType: “text”, contentType: “text/xml”, processData: false, data: DATA, success: function (response) { console.log(response); callback(response); }, error: function (response) { console.log(response); callback(null); } }); } 如何发送,我如何记录整个HTTP POST请求(HTTP标头+数据)? 谢谢。

DELETE命令未访问WebAPI控制器

在通过ASP.NET Web API提交请求时,我很难在我的Controller上获取DELETE方法。 它返回404,但我无法弄清楚原因。 GET和POST请求按预期工作,返回项目列表以及提供id时的单个项目,但是当我使用DELETE请求调用API时,我得到404错误。 场景: 1. ASP.NET Web窗体应用程序…… 虽然我已经安装了MVC4软件包以利用Web APIfunction,但它不是MVC应用程序。 2. global.asax中的路由表定义 RouteTable.Routes.MapHttpRoute( “Default”, “api/{controller}/{id}”, new { id = RouteParameter.Optional } ); 3.控制器定义 public HttpResponseMessage Post(Customer customer) { CustomerDb.Customers.AddObject(customer); CustomerDb.SaveChanges(); var response = new HttpResponseMessage(customer, HttpStatusCode.Created); response.Headers.Location = new Uri(Request.RequestUri, “/api/Customer/”+customer.id.ToString()); return response; } public CustomerDTO Get(int id) { CustomerDTO custDTO = null; Customer […]

jQuery获取HTTP URL请求

我最近尝试使用jQuery从URL获取一些响应。 因此,我将jQuery API Get Request Tutorial的get请求样本复制到我的项目中并尝试运行它,但是我的调试消息向我显示,它无法继续下去。 我使用简单的请求尝试了javascript Ajax库,但它没有用。 所以我问你,如果你能以某种方式帮助我。 这就是我所做的一切,但没有回应。 var url = “http://www.google.com”; $.get(url, function(data){ alert(“Data Loaded: ” + data); }); 我可能忘了包含ajax或jQuery库。 为了更好地理解,我有c和obj-c经验,这就是我认为库缺失的原因。 在每个样本中只有一个简短的url,如“test.php”。 我的完整HTTPurl是错误的吗? 谢谢你的高级答案。 Br Nic