The parameter string could not be transmitted via XMLHttpRequest

Hello, I'm currently facing an issue with sending request parameters through the XMLHttpRequest.send(params) method when trying to get a response from a Web Service. The request parameters seem to not be getting sent properly.

Below is the code snippet causing the problem:

<script type="application/javascript">
window.onload = function myFunc()
{
    var httpRes;
    if (window.XMLHttpRequest)
    {   
        httpRes=new XMLHttpRequest();
    }
    else
    { 
        httpRes=new ActiveXObject("Microsoft.XMLHTTP");
    }   
    httpRes.open("POST", "http://192.168.11.59:3333/Reports/GenerateMobReportJsonData", true);  
    var params = {'FromDate':'02/19/2013 17:30','ReportId':'1','LocationId':'1','ToDate':'02/19/2013 19:00','TeamId':'1'}
    httpRes.setRequestHeader('content-type', 'application/json');
    var jsonReq = JSON.stringify(params);
    //alert(jsonReq)
    httpRes.send(jsonReq);
}
</script>

I would greatly appreciate any assistance or insights on how to resolve this issue...

Answer №1

When utilizing 'Application/Json' as your communication protocol and your jQuery hosted server is different from your web service server, you may encounter a CrossDomain Request issue.

In order to resolve this, consider using Jsonp as the communication protocol instead.

Check out this example -

Requests between two separate servers should be made using the jsonp protocol.

You may also face similar problems like this one -

jQuery Ajax fails even with the HTTP 200 status

I hope this information proves useful to you.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Type parameters in TypeScript components

Below is the code snippet I am working with: const pageArea = (Component,title) => ({ ...props }) => { <Component {...props} /> } This works fine in JavaScript, but I am looking to convert it to TypeScript. This is what I have tried: functio ...

"Viewed By" aspect of Facebook communities

I'm working on implementing a feature that shows when a post has been seen, similar to Facebook groups, using JS and PHP. I've been able to track the number of times a post has been seen through scrolling actions, but now I want to determine if u ...

Tips for preventing the parent from being dragged along with its child

In my current React project, I have implemented a navigation bar where users can drag and rearrange items within the bar successfully. Now, I am working on rendering the navigation tree recursively so that inner navigations can also be draggable without c ...

JavaScript: Array methods and Functions

export function getPlanetNames(data) { const pNames = data.planets; const results = pNames.filter(function (getNames) { return getNames.name; }); return results; 'data' is stored in a separate file and consists of an object array wit ...

Apply a custom filter to ng-repeat results

Asking for advice on how to iterate over an array using ng-repeat and filter the contained objects based on a function property. Find more details in this Plunker link. Let's say we have an object like this: vm.show1 = function(){ return true; }; ...

Creating dynamic height based on width using JavaScript

I'm trying to make a rectangle responsive based on the width of the window. This is my current logic: aspectRatio = 16 / 9 win = { width: window.innerWidth, height: window.innerHeight, } get browser() { const width = this.win.width - 250 ...

Is it possible for Chrome to permit my extension to send HTTPS requests to a server with a self-signed certificate?

My question is about sending AJAX (HTTPS) requests to a server that I own from the background page of my Chrome extension. I have found that without adjusting browser settings, it is difficult to send such requests to an unsigned/self-signed server. I am c ...

Tips for integrating Chart.js into my AngularJS application?

I am a beginner with AngularJS and I'm currently developing an application on Ubuntu. While trying to add Chart.js using npm install chart.js, an error is being displayed as follows. npm WARN <a href="/cdn-cgi/l/email-protection" class="__cf_emai ...

"Utilize gulp-connect to store the root as an array

The gulp-connect documentation mentions that options.root can accept either an array or string. My situation involves having a build directory that I want to use as the root, along with a separate sources directory where all my source maps are located. Is ...

Merge the tap and doubletap Ionic events together

I have searched through a few examples, but I have not found anything that solves my problem. Here's what I need help with: I am trying to create an element that has two separate events - one for a single tap and another for a double tap. However, the ...

Grunt tip: Converting jshint results to HTML format

I've set up jshint to run with grunt successfully, but now I'm looking to have the output in HTML format. Below is my grunt configuration: module.exports = function(grunt) { // Project configuration. grunt.initConfig({ jshint: { ...

Is there a way to have text appear in a popup when I reach it while scrolling?

Is there a way to make the textblocks on my website increase in size or pop up when I scroll down to them? I've attempted to search for a solution online but have been unsuccessful in finding one. ...

Vue.js is able to update various models based on selection from a form dropdown

I have a dynamic select list in my app built with vue.js. I am trying to update a "details" box on the page with information fetched through an ajax request. You can view the code here: https://jsfiddle.net/pznej8dz/1/ I am puzzled as to why the sf_detail ...

There was an issue retrieving the value from the $.ajax() error function, as it returned [

After successfully receiving data from the input field and sending it to the database, everything seems to be working fine. However, when attempting to retrieve the data after sending it to the database, an error is encountered: [object HTMLInputElement]. ...

What possible reasons could cause an API request to result in an empty array being returned?

I recently encountered an issue when calling this API using npm request. The response I receive is an empty array, despite having loaded request, defined the content value at the top of the page (not displayed here), and modified the API key. Surprisingly, ...

What is an alternative method for invoking a child function within a parent component in React?

I managed to successfully call a function in a child component from a parent component in React without using refs. However, I'm unsure if my approach is just a cheap hack. Is there a better way to accomplish this task? While I've been reading t ...

Creating a multi-tiered dropdown menu in the navigation bar with the help of Bootstrap 4 and Angular 7

My goal is to implement a multilevel dropdown using bootstrap 4 and angular 7. While I successfully created a simple dropdown in the navbar following the official bootstrap documentation, I struggled to make the multilevel dropdown work. After referring ...

Problem with overlapping numbers in the Vis network

I am currently working on a project using Angular 8 and Visnetwork. Everything is going well, but I am facing an issue with overlapping numbers on lines. Is there a way to adjust the position of the numbers on one line without separating the lines? Can s ...

Tips for transferring a geolocation lat lng to the `ll` property of a different function in React

I have a Geolocation.js file that retrieves the geolocation data and logs it to the console. This file is imported into an index.js file and I need to use the lat and lng values that are logged to replace the hardcoded values in the ll parameter in the fol ...

assistance required (javascript and jquery timer function)

Whenever the button is clicked, a timer of 2 minutes starts. If the button is clicked once and the 2-minute timer completes before another click, everything works perfectly. However, if the user clicks the button before the 2 minutes are up, the timer rese ...