ajax pass array to python background

tags: Pit experience

Purpose: pass [1,2,3,4] such an array to the background

I was struggling with this issue for a while, the first was to use the json string

front end: 
ids = [1,2,3,4]
data = {
	"ids":ids
}
data = JSON.stringify(data)
$.ajax({
 url: "{{ url_for('Index.Buy') }}",
 data: data,
 success: function (data) {
     console.log("Successful purchase");
 }
});
Backstage: 
 Never found the right direction. . . .

Later found request.args.getlist()

This mentality collapsed. . . . . .

ids = [1,2,3,4]
$.ajax({
 url: "{{ url_for('Index.Buy') }}",
 data: {
	"ids":ids
},
 traditional:true, #Pass array must
 success: function (data) {
     console.log("Successful purchase");
 }
});
Backstage: 
ids = request.form.getlist("ids")
 OK. . .

Intelligent Recommendation

Use AJAX to pass the JS object array to the Java background server

Front End Page JS Write: Import Ali's JAR package: Background Java server Receive: Entity class properties correspondence parameter name:  ...

Use Ajax to pass the JSON array to MVC background front end

Use Ajax to pass the JSON array to MVC background front end Front -end code: Background code:...

SpringMVC pass parameters via ajax list objects or background objects to pass array

surroundings Reception to pass parameters to the background Reception using ajax Background use springMVC Transmission parameters are a plurality of objects N JSON object and JSON string In SpringMVC ...

Ajax pass array

Passing data in ajax can be used   Background reception can be used:   Note: The key is the $.ajax({traditional: true,}) setting, not the next String[] checkedIds can't receive the value. &n...

Ajax pass array and object

Ajax pass array: Ajax pass object:  ...

More Recommendation

ajax pass an array parameter

Examples   ...

ajax pass an array to springmvc

Backstage $.ajax({ url: “/bill/distribute”, type: “post”, data: {“ids”: 1,2,3,4,5,}, dataType: “json”, success: function (data) { Global.success(success...

Using ajax to pass an array

If you want to use ajax to pass the array to the background,traditional must be set to true。...

ajax pass array parameters

similar parameters...

ajax how to pass array

traditional: Whether to use traditional shallow serialization....

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top