I'd like to send some data using an XMLHttpRequest in JavaScript. Say I have the following form in HTML: <form name="inputform" action="somewhere" method="post"> <input type="hidden" value="person" name="user"> <input type="hidden" value="password" name="pwd"> <input type="hidden" value="place" name="organization"> <input type="hidden" value="key"
我想用JavaScript中的XMLHttpRequest发送一些数据。 假设我在HTML中具有以下表单: <form name="inputform" action="somewhere" method="post"> <input type="hidden" value="person" name="user"> <input type="hidden" value="password" name="pwd"> <input type="hidden" value="place" name="organization"> <input type="hidden" value="key" name="requiredkey"> </fo
I'm developing a page that pulls images from Flickr and Panoramio via jQuery's AJAX support. The Flickr side is working fine, but when I try to $.get(url, callback) from Panoramio, I see an error in Chrome's console: XMLHttpRequest cannot load http://www.panoramio.com/wapi/data/get_photos?v=1&key=dummykey&tag=test&offset=0&length=20&callback=processImages&m
我正在开发一个页面,通过jQuery的AJAX支持从Flickr和Panoramio中提取图片。 Flickr方面工作正常,但是当我尝试从Panoramio获取$.get(url, callback)时,我在Chrome控制台中看到一个错误: XMLHttpRequest无法加载http://www.panoramio.com/wapi/data/get_photos?v=1&key=dummykey&tag=test&offset=0&length=20&callback=processImages&minx=-30&miny=0&maxx=0&maxy=150。 Access-Cont
i read all the posts about digest authentication and i'm trying but i have any problem, i have a restlet with the digest authentication implemented, and with a javascript api i'm trying to authenticate. First, i do the xmlhttprequest POST to the server (from file:// to localhost:8111 so i have the CORS problem but is solved), well, the server response with the 401 and with the WWW-Authe
我阅读所有关于摘要身份验证的帖子,我试图但我有任何问题,我有一个restlet与摘要身份验证实施,并与我试图验证的JavaScript API。 首先,我将xmlhttprequest POST发送到服务器(从file://到localhost:8111,所以我有CORS问题但已解决),以及服务器对401和WWW-Authenticate头的响应: WWW-Authenticate:Digest realm="Guard", domain="/", nonce="MTMzOTA5Mjk1NTE2NDo0NzY2NjJiOTgyMjE1ZDc0OWU3NzM5MTkzMWNjNGQzNw=
如何使用jQuery设置和取消设置cookie,例如创建名为test的cookie并将值设置为1 ? See the plugin: https://github.com/carhartl/jquery-cookie You can then do: $.cookie("test", 1); To delete: $.removeCookie("test"); Additionally, to set a timeout of a certain number of days (10 here) on the cookie: $.cookie("test", 1, { expires : 10 }); If the expires option is omitted, then the cookie becomes
如何使用jQuery设置和取消设置cookie,例如创建名为test的cookie并将值设置为1 ? 查看插件: https://github.com/carhartl/jquery-cookie 你可以这样做: $.cookie("test", 1); 删除: $.removeCookie("test"); 此外,要在Cookie上设置特定天数的超时时间(此处为10): $.cookie("test", 1, { expires : 10 }); 如果省略了expires选项,则cookie将成为会话cookie,并在浏览器退出时被删除。 涵盖所有选项: $.cook
I have a page that allows the user to download a dynamically-generated file. It takes a long time to generate, so I'd like to show a "waiting" indicator. The problem is, I can't figure out how to detect when the browser has received the file, so I can hide the indicator. I'm making the request in a hidden form, which POSTs to the server, and targets a hidden iframe for i
我有一个页面允许用户下载一个动态生成的文件。 生成需要很长时间,所以我想显示一个“等待”指标。 问题是,我无法弄清楚如何检测浏览器何时收到文件,所以我可以隐藏指示器。 我以隐藏的形式发出请求,发送到服务器,并针对其结果隐藏iframe。 这是因为我不会用结果替换整个浏览器窗口。 我在iframe上侦听一个“加载”事件,希望它在下载完成时触发。 我用该文件返回一个“Content-Disposition:attachment”标题,这会导致
如何使用AJAX提交表单使用enctype =“multipart / form-data”? Short answer: you don't. You cannot upload files via AJAX. The usual workaround is to set the target of your form to a hidden iframe and submit the form there, using a normal, non-AJAXy POST, to achieve the desired effect: <form target="hiddenIframe" method="post" enctype="multipart/form-data"> ... </form> <ifra
如何使用AJAX提交表单使用enctype =“multipart / form-data”? 简短的回答:你没有。 你不能通过AJAX上传文件。 通常的解决方法是将表单的目标设置为隐藏的iframe并使用普通的非AJAXy POST提交表单,以达到期望的效果: <form target="hiddenIframe" method="post" enctype="multipart/form-data"> ... </form> <iframe name="hiddenIframe" id="hiddenIframe" style="display: none;" /> 有一个使用
I have a piece of client side code that exports a .docx file from Google Drive and sends the data to my server. It's pretty straight forward, it just exports the file, makes it into a blob, and sends the blob to a POST endpoint. gapi.client.drive.files.export({ fileId: file_id, mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }).then(function (resp
我有一段客户端代码,用于从Google Drive中导出.docx文件并将数据发送到我的服务器。 它非常简单直接,它只是导出文件,将其放入Blob中,并将Blob发送到POST端点。 gapi.client.drive.files.export({ fileId: file_id, mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }).then(function (response) { // the zip file data is now in response.body var blob = new Blo
I need to send data by POST method. For example, I have the string "bla&bla&bla". I tried using encodeURI and got "bla&bla&bla" as the result. I need to replace "&" with something correct for this example. What kind of method should I call to prepare correct POST data? UPDATED: I need to convert only charachters which may broke POST requ
我需要通过POST方法发送数据。 例如,我有字符串“bla&bla&bla”。 我尝试使用encodeURI ,结果得到了“bla&bla&bla”。 我需要用本例中正确的内容替换“&”。 我应该调用哪种方法来准备正确的POST数据? 更新: 我只需要转换可能会破坏POST请求的charachters。 只有他们。 >>> encodeURI("bla&bla&bla") "bla&bla&bla" >>> encodeURIComponent("bla&bla&bla") "bla%26b
I need to convert my image to a base64 string so that i can send my image to a server. Is there any js file for this... ? Else how to convert it You can use the HTML5 <canvas> for it: Create a canvas, load your image into it and then use toDataURL() to get the base64 representation (actually, it's a data: URL but it contains the base64-encoded image). There are multiple approach
我需要将我的图像转换为base64字符串,以便我可以将图像发送到服务器。 有没有任何js文件...? 否则如何转换它 您可以使用HTML5 <canvas> : 创建一个画布,将图像加载到它中,然后使用toDataURL()获取base64表示(实际上,它是一个data: URL,但它包含base64编码的图像)。 有多种方法可以选择: 1.方法:FileReader 通过XMLHttpRequest将图像加载为blob,并使用FileReader API将其转换为dataURL: function
I'm writing a Web application that needs to store JSON data in a small, fixed-size server-side cache via AJAX (think: Opensocial quotas). I do not have control over the server. I need to reduce the size of the stored data to stay within a server-side quota, and was hoping to be able to gzip the stringified JSON in the browser before sending it up to the server. However, I cannot find muc
我正在编写一个Web应用程序,需要通过AJAX将JSON数据存储在小型,固定大小的服务器端缓存中(请考虑:Opensocial配额)。 我无法控制服务器。 我需要减小存储数据的大小以保留在服务器端配额中,并且希望能够在将浏览器中的字符串化JSON发送到服务器之前对其进行gzip压缩。 但是,我无法找到Gzip的JavaScript实现方式。 关于如何在发送之前在客户端压缩数据的任何建议? 编辑在http://pieroxy.net/blog/pages/lz-string/