mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Initial commit for api.js
- GET JSON call with console output - Provide filters
This commit is contained in:
parent
2edb865528
commit
83dd068fec
21
InvenTree/static/script/inventree/api.js
Normal file
21
InvenTree/static/script/inventree/api.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
function inventreeGet(url, filters={}) {
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
type: 'get',
|
||||||
|
data: filters,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(response) {
|
||||||
|
console.log('Success GET data at ' + url);
|
||||||
|
return response;
|
||||||
|
},
|
||||||
|
error: function(xhr, ajaxOptions, thrownError) {
|
||||||
|
console.error('Error on GET at ' + url);
|
||||||
|
console.error(thrownError);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getParts(filters={}) {
|
||||||
|
return inventreeGet('/api/part/', filters);
|
||||||
|
}
|
@ -59,6 +59,8 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js_load %}
|
{% block js_load %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script type='text/javascript' src="{% static 'script/inventree/api.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
|
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
@ -206,4 +208,6 @@
|
|||||||
url: "{% url 'api-stock-list' %}",
|
url: "{% url 'api-stock-list' %}",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
getParts();
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user