javascript ajax post send an object
JavaScript
function postAjax(url, data, success) { var params = typeof data == 'string' ? data : Object.keys(data).map( function(k){ return encodeURIComponent(k) + '=' + encodeURIComponent(data[k]) } ).join('&');
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); xhr.open('POST', url); xhr.onreadystatechange = function() { if (xhr.readyState>3 && xhr.status==200) { success(xhr.responseText); } }; xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send(params); return xhr;}
// example requestpostAjax('http://foo.bar/', 'p1=1&p2=Hello+World', function(data){ console.log(data); });
// example request with data objectpostAjax('http://foo.bar/', { p1: 1, p2: 'Hello World' }, function(data){ console.log(data); });
Also in JavaScript:
- Title
- how to get the year in javascript
- Category
- JavaScript
- Title
- angular material table
- Category
- JavaScript
- Title
- angular submit form programmatically
- Category
- JavaScript
- Title
- how to attach javascript to html
- Category
- JavaScript
- Title
- credit card mask js
- Category
- JavaScript
- Title
- create table jquery
- Category
- JavaScript
- Title
- how to make javascript function consise
- Category
- JavaScript
- Title
- adding delay in javascript foreach loop
- Category
- JavaScript
- Title
- function in react
- Category
- JavaScript
- Title
- apache log format json
- Category
- JavaScript
- Title
- how to debug javascript
- Category
- JavaScript
- Title
- express get params after ?
- Category
- JavaScript
- Title
- append data in value array javascript
- Category
- JavaScript
- Title
- classList has class
- Category
- JavaScript
- Title
- empty textarea using jquery
- Category
- JavaScript
- Title
- angular run behind proxy
- Category
- JavaScript
- Title
- get random item from array javascript
- Category
- JavaScript
- Title
- angular property binding
- Category
- JavaScript
- Title
- how to read json file in python
- Category
- JavaScript
- Title
- disabling submit button until all fields have values
- Category
- JavaScript
- Title
- javascript check for duplicates in array
- Category
- JavaScript
- Title
- how to create a new react native project
- Category
- JavaScript
- Title
- angular add object to array
- Category
- JavaScript
- Title
- express and node
- Category
- JavaScript
- Title
- how to update jquery datatable row cell value
- Category
- JavaScript
- Title
- how to check if variable is array in js
- Category
- JavaScript
- Title
- disable textbox jquery
- Category
- JavaScript
- Title
- javascript check if is array
- Category
- JavaScript
- Title
- how to paste in input field react native
- Category
- JavaScript
- Title
- how to make a factorial function in javascript
- Category
- JavaScript
- Title
- javascript check if dom element exists
- Category
- JavaScript
- Title
- basic javascript
- Category
- JavaScript
- Title
- check palindrome js
- Category
- JavaScript
- Title
- componentwillreceiveprops hooks
- Category
- JavaScript
- Title
- how to check if window size of browser s changed javascript
- Category
- JavaScript
- Title
- for of array javascript
- Category
- JavaScript
- Title
- javascript after split then trim whitespace
- Category
- JavaScript
- Title
- How to change htm h1 from nodejs
- Category
- JavaScript
- Title
- concantene number in js
- Category
- JavaScript
- Title
- how to create a variable in javascript
- Category
- JavaScript
- Title
- javascript ajax
- Category
- JavaScript
- Title
- export to logs to elasticsearch node from fluend container k8s
- Category
- JavaScript
- Title
- javascript array push method
- Category
- JavaScript
- Title
- how to print two arrays together
- Category
- JavaScript
- Title
- how to access global scope in to local scope using javascript examples
- Category
- JavaScript
- Title
- example of while loop in javascript with array length
- Category
- JavaScript
- Title
- aws amplify get JWT TOKEN
- Category
- JavaScript
- Title
- AWS SDK for javascript assumerole with proxy
- Category
- JavaScript
- Title
- how to make a proxy server node.js
- Category
- JavaScript
- Title
- in javascript how to split string
- Category
- JavaScript
- Title
- eval in js
- Category
- JavaScript
- Title
- dom create element
- Category
- JavaScript
- Title
- currying in javascript
- Category
- JavaScript
- Title
- how to find length of array in javascript without using length method
- Category
- JavaScript
- Title
- angular observable subscribe and unsubscribe
- Category
- JavaScript
- Title
- angular bootstrap not working
- Category
- JavaScript
- Title
- adjust() js
- Category
- JavaScript
- Title
- binary to int javascript
- Category
- JavaScript
- Title
- es6 closures
- Category
- JavaScript
- Title
- get last char javascript
- Category
- JavaScript
- Title
- how to program an array in js
- Category
- JavaScript
- Title
- how to take an element out of an array in javascript
- Category
- JavaScript
- Title
- electron Uncaught ReferenceError: require is not defined at recorder.js:1
- Category
- JavaScript
- Title
- error Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class.
- Category
- JavaScript
- Title
- get value from textbox in vanilla javascript
- Category
- JavaScript
- Title
- javascript add function to onchange event
- Category
- JavaScript
- Title
- get value onChange from mat-select angular
- Category
- JavaScript
- Title
- how to print to console javascript
- Category
- JavaScript
- Title
- grepper not showing
- Category
- JavaScript
- Title
- javascript check if element is visible on screen
- Category
- JavaScript
- Title
- button not clicking for random jokes in javascript
- Category
- JavaScript
- Title
- clone aJavaScript object
- Category
- JavaScript
- Title
- document delete element
- Category
- JavaScript
- Title
- how to make a show password button
- Category
- JavaScript
- Title
- disregard empty field in array
- Category
- JavaScript
- Title
- array chunk javascript
- Category
- JavaScript
- Title
- how to move a block in javascript
- Category
- JavaScript
- Title
- .pop js
- Category
- JavaScript
- Title
- javascript array column
- Category
- JavaScript
- Title
- clear the console while in strict mode
- Category
- JavaScript
- Title
- is sublime text a good editor
- Category
- JavaScript
- Title
- array of objects javascript
- Category
- JavaScript
- Title
- how to make a var and sprite in javascript
- Category
- JavaScript
- Title
- get id of clicked element javascript
- Category
- JavaScript
- Title
- change value of drop down using jquery
- Category
- JavaScript
- Title
- javascript capitalize first letter
- Category
- JavaScript
- Title
- get element by class
- Category
- JavaScript
- Title
- Alert.alert closing expo
- Category
- JavaScript
- Title
- expo open app settings
- Category
- JavaScript
- Title
- Angularjs datetime
- Category
- JavaScript
- Title
- check if date equal js
- Category
- JavaScript
- Title
- how to run cypress test
- Category
- JavaScript
- Title
- how to convert audio blocb to base64 string
- Category
- JavaScript
- Title
- how to add class to element on mouseclick with js
- Category
- JavaScript
- Title
- change title react
- Category
- JavaScript
- Title
- docker node label add
- Category
- JavaScript
- Title
- for Loop continue
- Category
- JavaScript
- Title
- javascript add row to table
- Category
- JavaScript
- Title
- how to find remainder in javascript
- Category
- JavaScript
- Title
- detox scroll to element
- Category
- JavaScript