ITsolutionWizard
asked on
jquery, encodeurlcomponent
Below jquery ajax is working fine. What I want to do is below:
url: GetModelListJSon + encodeURIComponent("(011,1 15217)"),
I want to be
var customerNo = "111";
var companyNo = "222";
and I got error alert in Chrome saying below:
XMLHttpRequest cannot load http://clientaccesstest.abc.com/wcf/orders/RestService/QuoteServiceJVC/GeModelList(.....)?_=1428433644469. No 'Access-Control-Allow-Orig in' header is present on the requested resource. Origin 'http://localhost:62937' is therefore not allowed access.
The web service is working fine without cross domain issue. When I hard code like below, it works fine. Any ideas how to fix it?
url: GetModelListJSon + encodeURIComponent("(custo merNo,comp anyNo)"),
function GetModelList(divisCode)
var customerNo = "315217";
var GetModelListJSon = "http://clientaccesstest.abc/GetModel";
$(document).ready(function () {
$.ajax({
crossDomain: true,
cache: false,
type: "GET",
async: false,
dataType: "json",
contentType: 'text/plain',
url: GetModelListJSon + encodeURIComponent("(011,1 15217)"),
success: function (data) {
$('#data').html(data);
if (data == null)
return;
resultObj = jQuery.parseJSON(data);
if (resultObj.Status != 'Failed') {
$('#json').html(setModelIn fo(resultO bj.Data,di visCode));
}
},
error: function (xhr,status,error) {
$('#data').html(xhr.respon seText);
alert(xhr.responseText + " : error GetModelListJSon");
alert(status);
alert(error);
}
});
});
}
url: GetModelListJSon + encodeURIComponent("(011,1
I want to be
var customerNo = "111";
var companyNo = "222";
and I got error alert in Chrome saying below:
XMLHttpRequest cannot load http://clientaccesstest.abc.com/wcf/orders/RestService/QuoteServiceJVC/GeModelList(.....)?_=1428433644469. No 'Access-Control-Allow-Orig
The web service is working fine without cross domain issue. When I hard code like below, it works fine. Any ideas how to fix it?
url: GetModelListJSon + encodeURIComponent("(custo
function GetModelList(divisCode)
var customerNo = "315217";
var GetModelListJSon = "http://clientaccesstest.abc/GetModel";
$(document).ready(function
$.ajax({
crossDomain: true,
cache: false,
type: "GET",
async: false,
dataType: "json",
contentType: 'text/plain',
url: GetModelListJSon + encodeURIComponent("(011,1
success: function (data) {
$('#data').html(data);
if (data == null)
return;
resultObj = jQuery.parseJSON(data);
if (resultObj.Status != 'Failed') {
$('#json').html(setModelIn
}
},
error: function (xhr,status,error) {
$('#data').html(xhr.respon
alert(xhr.responseText + " : error GetModelListJSon");
alert(status);
alert(error);
}
});
});
}
ASKER
tried already. same issue is still occurred.
Is this value correct? var GetModelListJSon = "http://clientaccesstest.abc/GetModel";
If you test:
Questions:
Q1. Any particular reason you are using encodeURIComponent?
Q2. If you are using ASP.NET MVC can you post your action signature as well as the associated mapping?
In MVC we usually pass parameters as "api/{controller}/{par1}/{ par2}" as shown here.
If you test:
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Variables</h1>
<p id="demo"></p>
<script>
var customerNo = "111";
var companyNo = "222";
var z = "(" + customerNo +"," + companyNo+")";
document.getElementById("demo").innerHTML = encodeURIComponent(z);
</script>
</body>
</html>
is returning the correct string. Your error states GetModelList not GetModel (unless you are using MVC routing)Questions:
Q1. Any particular reason you are using encodeURIComponent?
Q2. If you are using ASP.NET MVC can you post your action signature as well as the associated mapping?
In MVC we usually pass parameters as "api/{controller}/{par1}/{
ASKER
Q1: I do not have to use encodeURLComponent.
Q2: the client is html with jquery call. Not MVC.
Q2: the client is html with jquery call. Not MVC.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
with:Open in new window