Ubuntu Pastebin

Paste from senaps at Sun, 7 May 2017 05:30:53 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{% if products %}
<div class="products">
  <form class="sendproduct" action="" method="POST">
  please select a product: <select class="products_list" id="products_list" name="product_id">
    {% for product in products %}
        <option value="{{ product.id }}"><a href="{{ product.git_url[:-4] }}">{{ product.name }}</a></option>
    {% endfor %}
  </select>
  </form>
</div>
{% endif %}


^^^^
||||
HTML CODE
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==--=-=-=-=-=-=--=-=-=-=-
 $('#products_list').change(function() {
    val = $( "#products_list option:selected" ).text();
      $.ajax({
            type: 'post',
            url: '{{ url_for('main.add_version_list')}}',
            data: $('.sendproduct').serialize(),
  success: function (data) {
  console.log(data)
            }
          });
});

^^^^
||||
AJAX CODE
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-
product_id=3

^^^^
||||
raw data that is sent from jquery/ajax to the server acording to the firefox developer tools!

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-
@mod.route('add_version_list/', methods=['POST'])
def add_version_list():
    product_id = request.form['product_id']
    # products = Product.query.filter_by(product_id=product_id)
    # global_product_name = products.name
    return jasonify({"result":product_id })
    # return jsonify({"result": render_template('main/add/versions_ajax.html')})

^^^^
||||
THE CODE PROCESSING THE FORM
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not understand.</p>

^^^^
||||
RESULT I GET FROM DEVELOPER TOOLS ON ERROR 400.
Download as text