logo
down
shadow

Trying to POST only after an AJAX request but the POST keeps firing


Trying to POST only after an AJAX request but the POST keeps firing

By : user2954251
Date : November 22 2020, 01:01 AM
fixed the issue. Will look into that further I am trying to post after each completed ajax request .. , from the docs:
code :
$.get(....).complete(function(){
 $.post('/wp-admin/admin-ajax.php', {data:'hello'}, function(response) {
      console.log(response);
   });
})


Share : facebook icon twitter icon
Node JS Get Ajax request works but Post ajax request not works.Even Post data defined url is not responding

Node JS Get Ajax request works but Post ajax request not works.Even Post data defined url is not responding


By : Karina Maharani Tehu
Date : March 29 2020, 07:55 AM
I hope this helps . I am having a problem with writing express.js server, I tried to "post" and "get" some data I successfully "get" data via ajax, But when i "post" data rather than running .success(function (){...}), it runs .error(function(){}). I have been trying to figure out, matching code, but couldnt get the right pick, Please help ! Here is my Code of app.js on express.js , In Express.js you need to explicitly allow for POSTs to a url:
code :
app.get('/moredata1', mydata.getMoreData1);
app.post('/moredata1', mydata.getMoreData1); // <===
Why is this ajax post request executing a GET request with the data right before the post request is executed in Nodejs

Why is this ajax post request executing a GET request with the data right before the post request is executed in Nodejs


By : helgeklapper
Date : March 29 2020, 07:55 AM
seems to work fine It looks like you are submitting the form and the ajax request. Try adding the following to prevent the default submit action (GET).
code :
.submit(function(e) {
  e.preventDefault();
  //ajax code
}
How to use ajax post request response data to make another ajax post request?

How to use ajax post request response data to make another ajax post request?


By : John Sgoutas
Date : March 29 2020, 07:55 AM
I wish did fix the issue. We resolved the issue in chat.
The first request doesn't have the Content-Type header set to JSON, so the response isn't getting parsed. Setting dataType to json (the last argument to $.post) correctly sets the header and the response will be parsed as JSON. This means that data is an object, whose properties can be accessed, rather than a string.
Postman post request works but ajax post does not. Have checked client side js over and over

Postman post request works but ajax post does not. Have checked client side js over and over


By : iosDaveDev
Date : March 29 2020, 07:55 AM
around this issue first question ever on stackoverflow and boy do I need an answer. My problem is that I have an endpoint to create an item, and it works when I send a POST request with Postman. I'm using node and express: , What I would do:
code :
var httpClient = {

        get: function( url, data, callback ) {
            var xhr = new XMLHttpRequest();

            xhr.onreadystatechange = function () {
                var readyState = xhr.readyState;

                if (readyState == 4) {
                    callback(xhr);
                }
            };

            var queryString = '';
            if (typeof data === 'object') {
                for (var propertyName in data) {
                    queryString += (queryString.length === 0 ? '' : '&') + propertyName + '=' + encodeURIComponent(data[propertyName]);
                }
            }

            if (queryString.length !== 0) {
                url += (url.indexOf('?') === -1 ? '?' : '&') + queryString;
            }

            xhr.open('GET', url, true);
            xhr.withCredentials = true;
            xhr.send(null);
        },

        post: function(url, data, callback ) {
            var xhr = new XMLHttpRequest();

            xhr.onreadystatechange = function () {
                var readyState = xhr.readyState;

                if (readyState == 4) {
                    callback(xhr);
                }
            };

            var queryString='';
            if (typeof data === 'object') {
                for (var propertyName in data) {
                    queryString += (queryString.length === 0 ? '' : '&') + propertyName + '=' + encodeURIComponent(data[propertyName]);
                }
            } else {
                queryString=data
            }

            xhr.open('POST', url, true);
            xhr.withCredentials = true;
            xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            xhr.send(queryString);
        }
    };
AngularJS $http.post() firing get request instead of post

AngularJS $http.post() firing get request instead of post


By : Dana Brackett
Date : March 29 2020, 07:55 AM
help you fix your problem Seems the question is old and unanswered but google led me here. I hope someone will find this answer useful.
I had the same problem. $http was set to POST but server was returning error from GET request.
Related Posts Related Posts :
  • RangeError: Maximum call stack size exceeded with array.slice
  • node rest client get with local variable
  • If condition not executes while mouse move fastly
  • Count the number of displayed elements in a HTML list
  • Locate JavaScript source code in Emacs
  • Clean, Modular Code vs MV* Frameworks
  • infinite scroll without loading image
  • Backbone: reverse collection order with comparator
  • What do printers ignore?
  • jQuery UI .tabs() Contentless tab?
  • Execute Javascript alert() after page (visually) loaded
  • JavaScript - duplicating array doesn't work
  • Excessive clickable area below image
  • JavaScript Regex: Replace |b| with <b>
  • Unexpected value change in 2D array in JavaScript
  • Function doesnt see parameter as a array of objects
  • jQuery fetch keypress event on chrome and IE
  • How to enable jquery validate localization?
  • Cassandra map collection returned by node.js Helenus looks odd
  • angular ng-repeat with multiple filter options
  • Selecting Children without ID or Class names
  • How to uncheck a group of checkboxes when another checkbox is checked
  • Is hiding content by Javascript or jQuery Worth trying
  • Load XUL resource using javascript
  • XML to HTML text area from server file system
  • set focus() on textbox on form onload
  • es lint '' is assigned a value but never used' eventhough i have used it
  • Can "name" attribute be used for custom VueJS components
  • Get innerHTML of content when it is clicked
  • HTTPS causes CSS animations to not load? Very confused
  • How to hide other div apart from touched div to the band
  • Is global variable assignment atomic on NodeJS?
  • Datepicker onchangemonthyear beforeshowday
  • trying to render html files using jade but it still adresses it as a jade
  • Google Analytics - Understanding and Dissecting the Snippet: What is | | [ ];
  • Replacing "[aA09.b]." to "[aA09.b]\n" in in JavaScript
  • Why wrap a function definition in an immediate function?
  • Enable / disable jQuery script on switching to different tab in a HTML page
  • how can find return variable value outside anonymous function in node js mysql query function
  • Converting 1 to 0001 in javascript array
  • svg viewbox should not resize the text fontSize?
  • store newline character with string in a variable
  • MP4 videos in Flowplayer does not play in Windows 7 Chrome
  • jquery focusin event not firing
  • How to debug Vue application with google chrome
  • html 5 web app cache download complete javascript alert?
  • Ember.js setupController fired only once
  • How to validate a currency input
  • How to convert my Array of data to key & value pair
  • Statistics circles in CSS
  • So I wanted to make a trig solver in javascript?
  • Showing HighCharts series name on x-axis and in legend
  • In Rails, how can we pass parameters in script?
  • Build Fails: `npm rebuild node-sass --force`
  • Angular Datepicker change dateformat
  • Trying to extract data from between two sets of characters
  • Configuring Jest in WebStorm
  • Uncaught Error: Syntax error, unrecognized expression: tr.ec_portfolio_title,
  • JQuery fading in fading out continuously
  • Unexpected end of input (Line 1) and Undefined Function?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org