- Screen name: neelamtalreja12
neelamtalreja12's Profile
3 Posts
25 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- I have a dropdown integerated it with jquery from api response.I have an ADD button on clicking it the dropdown appends N number of times and i am able to fetch response in all dropdowns.The scenerio is:I need to add a vendor who is able to supply N no of products so on adding details i need to select the multiple products from the dropdowns and store the selected product in database.I am using post method.<script>$(document).ready(function(){$("#submit").click(function(){var vendor_name = $("#val-username").val();var vendor_email = $("#val-email").val();var vendor_phone= $("#val-phoneus").val();var vendor_address = $("#val-address").val();var product_ID = $("select").val();var xyz=[product_ID];var dataString = 'vendor_name='+ vendor_name + '&vendor_email='+ vendor_email + '&vendor_phone='+ vendor_phone + '&vendor_address='+ vendor_address + '&product_ID[0]=' + xyz[0] +'&product_ID[1]=' + xyz[1];if(vendor_name==''||vendor_email==''||vendor_phone==''||vendor_address==''){alert("Please Fill All Fields");}else{// AJAX Code To Submit Form.$.ajax({type: "POST",data: dataString,cache: false,success: function(result){if(result) {alert("Vendor Added Successfull");window.location.href= "vendor.html";//window.href.location='localhost/elearning/admin/categories.html';}}});}return false;});});$.getJSON(url, function (data) {$.each(data.records, function (index, value) {// APPEND OR INSERT DATA TO SELECT DROPDOWN PRODUCT LIST.$('#val-prod').append('<option value="' + value.product_ID + '">' + value.product_name + '</option>');;});});</script>The issue i am facing is as the remaining fields are single insertion i am able to dd it by post method so for selecting multiple products and storing it in database i need to use array.i tried storing PRODUCT ID in array form but it still adds single product.In VAR DATASTRING I AM UNABLE TO PASS ARRAY DATA FOR N PRODUCTS .My response from api is:I need to pass multiple product Id for a single vendor so as to store in database the products he suppliesProduct Id=["7","8","9"];How to POST array values in VAR DATASRING???
- 14-May-2018 12:13 AM
- Forum: Using jQuery
Hello,I have a UI where there is datatables and all the user details are in data tables coming through API Integration using Native Ajax with Edit and Delete option. I have Add user form and i want that on clicking Edit icon In UI all the details of particular user pass in my ADD user form to update user Details .I have API for Edit user details by his ID using PUT method I am able to pass the Id in the ADD User Form URL but not able to pass valuesCan Anyone provide some helpHere is the code:txt += "<a href='addsubadmin.html?id="+dd+"'><i class='fa fa-pencil fa-1x' aria-hidden='true' onclick='edit("+dd+")'></i></a> ;The dd(id="+dd+) variable passes particular user ID to the Add user form.I am able to display values in javascript alert for particular user but unable to pas the values.Hello,I am developing an Inventory Management system webapp.My view is using data tables showing list of vendord,stores and admin .i have an delete and Edit icon.Iwant to integrate my api in these icons .
THE API'S ARE
1.Delete user by id using post method
2. Edit user using update method
I am using AJAX JQUERY Api Integration.
Please provide some help
Code is as follows:
txt += "<a href='editsubadmin.html?id="+dd+"'><i class='fa fa-pencil fa-1x' aria-hidden='true'></i></a> | <a href='' onclick='delete_data("+dd+")'>";
txt += "<i class='fa fa-trash fa-1x'aria-hidden='true'></i></a></td>";
function delete_data() {
var obj, dbParam, xmlhttp, myObj, x,admin_ID
admin_ID=aa; console.log(admin_ID);
var xhr = new XMLHttpRequest(); xhr.withCredentials = true;
xhr.addEventListener("readystatechange",function () { if (this.readyState === 4) { console.log(this.responseText); } });
xhr.open("POST","API URL");
xhr.setRequestHeader("authorization", "Basic YWRtaW46MTIzNA==");
xhr.setRequestHeader("postman-token", "d99e506c-043e-fd5b-013e-8c81fedafb64");
xhr.send();
}
- «Prev
- Next »
Moderate user : neelamtalreja12
© 2013 jQuery Foundation
Sponsored by
and others.

