logo
down
shadow

Strange behavior when sending JSON over AJAX


Strange behavior when sending JSON over AJAX

By : Floris
Date : November 19 2020, 03:01 PM
wish help you to fix your issue Jquery processes your data before sending and uses the request's post formdata instead of putting JSON in the body of the request.
To avoid this, use processData: false and contentType: 'application/json':
code :
$.ajax({
    url: url,
    type: "POST",
    processData: false,
    contentType: 'application/json',
    data: JSON.stringify(data),
    success: function (result) {
        console.log("inside success");
    },
    error: function (error) {
        console.log("inside error");
    }
});


Share : facebook icon twitter icon
Strange loop behavior with JSON and AJAX

Strange loop behavior with JSON and AJAX


By : user2758427
Date : March 29 2020, 07:55 AM
should help you out We have these files: Action.php , Seems to me that when you do this:
code :
    $('.response').clone().attr('id', value.id).appendTo('#res-list');
    $('.response').clone().attr('id', value.id).removeClass('response').appendTo('#res-list');
ASP.net 3.5 WebMethod Strange Behavior, jQuery AJAX receives strange data

ASP.net 3.5 WebMethod Strange Behavior, jQuery AJAX receives strange data


By : user3707150
Date : March 29 2020, 07:55 AM
This might help you I found the solution... :)
First thing we could do is make our request async: false (BUT it'll impact our performance).. Instead, Im sending an ID (in my case SysID) and also bind it with my DIV id like the code below..
code :
<div id ="comment_<%= SysID %>"></div>
var ID = "#comment_" + val.SysteID;
 $(ID).setTemplateURL("../Templates/comments.htm");
 $(ID).processTemplate(comments);
Laravel: strange behavior when I try to serve ajax and non-ajax request on same route (Caching)

Laravel: strange behavior when I try to serve ajax and non-ajax request on same route (Caching)


By : ProNoob
Date : March 29 2020, 07:55 AM
seems to work fine Definitely a caching issue. Just to try and get some results, add this to your controller (ajax and non-ajax) to force-disable caching:
code :
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
sending 400 level error to ajax callback from action causing strange behavior

sending 400 level error to ajax callback from action causing strange behavior


By : Cesar Guerrero
Date : March 29 2020, 07:55 AM
around this issue I think another way to word you problem is you don't want the contents of the onsuccess function to be executed? if this is the case then move your @if (ViewData.ModelState.IsValid){ ... } to inside the OnSuccess function. if state is invalid that function would have no guts so nothing gets done.
personally I like keeping javascript separate from razor...even more, the javascript should reside in its own js file. in this case you could use razor to set a bool javascript variable to a function or object constructor, which would then do your success work only if variable was true.
Strange behavior of AJAX return JSON object

Strange behavior of AJAX return JSON object


By : Mạnh Toàn
Date : March 29 2020, 07:55 AM
This might help you So I request and get the object from the server like this: , If you have combination of data as response:-
code :
$(document).ready(function () {
    var req = $.getJSON("api/Appointments");
    req.done(function (data) {
        var result = false;
        $.each(data, function (key, value) {
            if ((value.Time == "9:00") && (value.Company == "Laakkonen")) { 
                result = true;
                return result; 
            }
        });
        if (result == true) {
            document.getElementById("A9").style.background = "red";
        } else {
            alert("error1");
        }
    });
    req.fail(function (error) {
        alert(error.statusText);
    });
});
if ((data[0].Time == "9:00") && (data[0].Company == "Laakkonen")) { 
    document.getElementById("A9").style.background = "red"; 
} else { 
    alert("error1"); 
}
Related Posts Related Posts :
  • Bootstrap DatePicker format mm/yyyy set max month
  • Firebase cloud firestore + auth: write only for signed in users
  • Getting jQuery.data functionality without jQuery
  • How to get incrementing serial numbers for new and removed items for jQuery sortable?
  • Highlighting a word or sentence in iframe, using javascript/Jquery
  • Calculate what percentage of a specific element has been scrolled into view
  • Knockout autocomplete with jquery doesn't allow to select custom value
  • react native - react-native-maps performance slow on iOS
  • ajax fallback when no internet connection
  • Show Textbox based on RadioButton selection or value when Page Loads
  • JS maximum call stack exceeded
  • Resetting object key values
  • How can i disable the toggle, preventing user to tap/click it?
  • How to include javascript file into LOV popups on apex oracle?
  • Javascript Angular 4 eventEmitter with ngClass
  • Webpack - module not found even though module exists
  • How to display following values using vue js?
  • Regexp: Allow only use of a few words and only once per word
  • CCapture.js webm video blacked out
  • Using a HTML hyperlink to call a JS function on the parent element
  • Return undefined from existing property in javascript model
  • What is the Difference Between These two jQuery Code Snippets?
  • How to get Network Speed in WebRTC
  • How to get text from selected value in a dropdownlist which is js based
  • window is not defined angular universal third library
  • Angularjs ng-repeat stylization depending on previous value
  • Trying to implement Fittext.js
  • Calculate number of match in array Lodash
  • Jquery Smooth Scroll Using Offset.top
  • How to extract data to React state from CSV file using Papa Parse?
  • How to add unique links to google maps markers
  • How to use if condition in a tool bar in java script
  • Ajax filter in django not showing in HTML
  • data collection with Javascript
  • Rotate image on lightbox2 load
  • Prevent body from scrolling when a Pop-Up is open
  • How to copy files that do not need to be compiled in Gulp?
  • Array not assigned to variable? How does this work and what exactly is it doing?
  • Sorting associative array of objects in javascript
  • Changing Icon in Sap.m.tree having CustomTreeItem
  • Merge two array of objects based on a key
  • javascript in css not working
  • Passing only clicked element to onClick function - reactjs
  • React boilerplate doesn't load js files in the index.html
  • is Child service inside child component visible in the Parent component?
  • Check if data attribute value equals a string
  • How to get value of child tag of a button tag
  • How to access subjects of selected mails in Apple Mail using JavaScript?
  • How to get all dynamically set inline-style CSS in jQuery?
  • Error: Module "html" does not provide a view engine (Express)
  • Random Image in <Div> from array
  • Slider with touch function
  • ReactJS Component Architecture Problems / Nested Components or Single Component Manager
  • Javascript: Caching within Closure doesn't work
  • HTM5 Canvas Drawing App: How Do I Select The Color?
  • Assigning Events using HTML DOM
  • html5 getUserMedia() portrait mode
  • How to avoid 'headers already sent' within Promise chain?
  • Get a result from a react native app integrated into an existing android app
  • Why does the value of input field return undefined
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org