http-post

Set “enctype” attribute to “application/json”

有些话、适合烂在心里 提交于 2019-12-05 14:08:02
Here is my code for making POST request: function post(path, params, method) { method = method || "post"; // Set method to post by default if not specified. // The rest of this code assumes you are not using a library. // It can be made less wordy if you use one. var form = document.createElement("form"); form.setAttribute("method", method); form.setAttribute("action", path); form.setAttribute("enctype", "application/json"); for(var key in params) { if(params.hasOwnProperty(key)) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField

With AngularJS, I don't want to set the global $http.defaults.headers.common. Can I send my custom header with each $resource call?

穿精又带淫゛_ 提交于 2019-12-05 13:54:25
I'm calling a back-end server that I cannot control. Currently it's using jQuery ajax like this: return $.ajax({ type: "POST", url: "/api/cases/store", contentType: "application/json", data: JSON.stringify(parameters), headers: { "Authorization": cred } : {} }) // ... etc. I want to convert it to use the $resource service, and got it working doing this $http.defaults.headers.common['Authorization'] = cred; return $resource('/api/cases/store').save(); The only problem is that I'm having to set the global $http service defaults with the auth credentials. I am seeing that you're supposed to be

Binding nested model with MVC3 on HttpPost

我只是一个虾纸丫 提交于 2019-12-05 13:21:59
I am new to MVC3. I have a submit button on a form and I want to bind a model which has 2-3 nested object models with many properties inside. Is there a way to bind these nested objects without using EditorFor; so that when I submit the form I will take on ActionResult(Object model) on model that is being returned, the nested object models with their values without having to implement hidden values or forms behind on html? basically you need enough values to identify your model again. So you can go with a Id in a hidden field and all the properties you want to change. To recreate your model

Send and receive data from server using 6.0 API (Android)

那年仲夏 提交于 2019-12-05 12:42:46
I'm really confused, i'm trying to develop a simple function that allow me to send and receive data from a server. The operation is as follows: In an activity I execute an HTTP POST to a PHP file on a server, the "PHP file" gets the data that i send (tipically a string), and executes a query using the parameters sent over http. Example: My android app send a string with this value "PIPPO", in the PHP file there is a query, for example: $value = PIPPO /* data received from android app*/ Select * from characters where(characters.name=".$value.") p.s. all data use JSON format The problem is: i

Spring @RequestParam Map<String, String> does not work in POST method

拥有回忆 提交于 2019-12-05 12:26:42
from the Spring documentation I took the following: public @interface RequestParam Annotation which indicates that a method parameter should be bound to a web request parameter. Supported for annotated handler methods in Servlet and Portlet environments. ... If the method parameter is Map or MultiValueMap and a parameter name is not specified, then the map parameter is populated with all request parameter names and values. Now I have created a controller for test purposes. It has a GET and a POST method and each uses a @RequestParam java.util.Map as only parameter. In the method body I am only

How to make a Python HTTP Request with POST data and Cookie?

回眸只為那壹抹淺笑 提交于 2019-12-05 11:05:09
问题 I am trying to do a HTTP POST using cookies in Python. I have the values of URL, POST data and cookie. import urllib2 url="http://localhost/testing/posting.php" data="subject=Alice-subject&addbbcode18=%23444444&addbbcode20=0&helpbox=Close+all+open+bbCode+tags&message=alice-body&poll_title=&add_poll_option_text=&poll_length=&mode=newtopic&sid=5b2e663a3d724cc873053e7ca0f59bd0&f=1&post=Submit" cookie = "phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22userid

Compojure handler friend/authenticate eats body of POST request

杀马特。学长 韩版系。学妹 提交于 2019-12-05 10:55:35
How can I safely get the content of the :body InputStream from compojure? See related but different question for background. I'm trying to authenticate my ring routes with Friend using compojure handler/site but when I try to read the :body from an http POST request (which is a Java InputStream ), it is closed: 23:01:20.505 ERROR [io.undertow.request] (XNIO-1 task-3) Undertow request failed HttpServerExchange{ POST /paypal/ipn} java.io.IOException: UT000034: Stream is closed at io.undertow.io.UndertowInputStream.read(UndertowInputStream.java:84) ~[undertow-core-1.1.0.Final.jar:1.1.0.Final] at

Circular view path

久未见 提交于 2019-12-05 10:05:31
I am using Spring MVC 3 and all I am trying to do is submitting a form with post request and redirecting the post request handler on the controller to some page. But I am getting the following error when I try to do that: javax.servlet.ServletException: Circular view path [thanks.htm]: would dispatch back to the current handler URL [/wickedlysmart/thanks.htm] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.) Following is the code I am using: Request handler: @RequestMapping(method=RequestMethod.GET, value="thanks")

Android : Upload image to PHP server

女生的网名这么多〃 提交于 2019-12-05 09:46:34
I have write a script to upload an image taken from camera to my server. I get 200OK response but I don't see my image on my server in uploads/ folder : Maybe my script contain an error. Could you help me please ? My example is the following link : http://androidexample.com/Upload_File_To_Server_-_Android_Example/index.php?view=article_discription&aid=83&aaid=106 Here is the compleete Android class : import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.net.HttpURLConnection; import java.net.MalformedURLException

rails 4 with link_to and method post with strong parameters

一曲冷凌霜 提交于 2019-12-05 09:46:27
I'm stuck in a problem which can't be that complicated, but I'm just not getting things right. Assuming I've got two Models: class Notification < ActiveRecord::Base belongs_to :device validates :number, presence: true end and class Device < ActiveRecord::Base belongs_to :user has_many :notifications, :dependent => :destroy //rest omitted for brevity end with nested routes like so: resources :devices do resources :notifications end and a notifications controller like so: class NotificationsController < ApplicationController before_filter :authenticate_user! before_action :set_device, :only => [