I'm trying to send a upload request for Google Analytics. I'm trying to use
$.ajax({
url: 'https://www.googleapis.com/upload/analytics/v3/management/accounts/76065140/webproperties/UA-76065140-1/customDataSources/5Qtzai0hSAatCidaDzhyHg/uploads',
method:"POST",
success: function(){
alert('123');
}
});
It returns Status Code:401 Login Required. Do I need to log in? I have created a service private key (in json), but how can I use the key?
Where do I add it to the request?
im try
$.ajax({
url: 'https://www.googleapis.com/upload/analytics/v3/management/accounts/76065140/webproperties/UA-76065140-1/customDataSources/5Qtzai0hSAatCidaDzhyHg/uploads',
data:"key=MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCS/0bCGAff/iCs\nBW8hGSu9F7iU95qjzwaf6xaNbxUcbYxUeIdLeFQpsYvMDuc2RToV56Yt9vc+40s2\nfGHVO2DfF4JJv3hJHdb/Emc0dPfJ/86riONbY2vTGsx9kxToruRqywzDaH/LsIL8\nxLPDDV3RmQ0XKuCS0hGlPakPeyOi+nLikAiVyNE6vHVKmTrcDEL6BKkM+l2BLa/m\n0jZH8GmxBmCLxzK4zWs0kFh9SSXjfC6f7Ydr1XR8U4bSadD6t2GSCZ54heXF2Y61\neLAPWViIGcWJevLzJdV6p4Tz3dooBREKO8QIpWV6CD/H3Z9lhuSrq/tsQcjv9u/P\nB/xfbREnAgMBAAECggEAOd3CNhANsZCxveYZvDbTcAnRgNsEBi4uVm/OHfk3n0xE\nrNARupTw1MTu2nKXdFbGKe9aDMgmxpvldNp8DNvmI4x2np+AM5BKnXjaJd1R2jQY\nYJBvp/84aA8pptlqprqKcrviF16gyEeBGQ46EbPGVgdhDtizNTj690iRr+Vyvuot\nl0J9DaE7A/f97TRRdOWzZnsnP6Hy37s0OLgRioq3f1hMm8KcCibnGTQpti+b8lAZ\n0A75f/GE3V0DnPscvrgiFVjnYzdtcH1XXXX41hop+fe0c9gbIvGyfllZGzDo54Cu\n5w31DLDIIqvOyG0o7DW4cUWchnFhcUrllHFE+ZP0kQKBgQDPEERaXn7sWqnTkueS\nLqbvpfGG4RePCzR+Ktan+xFmWlvFpNk5DacfUbpKN9iemFB013MxNvFBofpT3lBX\nhO5Q4r6LQvTDU+nTJJMXtHC7FoMQ7k4HDdm1VWQ1v56wR0IlZ3/alkkg/3GFXo/0\nNIOZ1BkYqG8mI+4A3r+Pk0QySQKBgQC1vOGcpr1M7Kox0MG3qyvoqm2NpepXxEYi\n+tI+kGI+F1nDk0cVp0U0I70wnF7f2JdMWihWrH3Ti4MxXavtwfv7Ogt425401Tyb\nR2opYxCz3jo11grTokAOFeJRnCioVz6YU26P6AHw/kkd73OASo7PsIHFV9VL4D6R\nVTW55lEn7wKBgQCaPkDcnHWptOO64jy0LSJXdGLVmYlGGg+xSFH8cc8FUpv4P5M8\np8ntT6EYtj8b7NRKJU/+wjG3NWTW4s0wVKp+AFn2PRs9AZ41lZIo31X2V4+spgfj\nw1KAfKqYSzR3la1VVaLs/nRdK0uyEL3lKNU7Wr6TGq0pWSxq44MI/aeYWQKBgQCu\nDnOJ48vjk7rBMS2HKgJIuIlqI2CYpFuD/vNDhmcBDr4i6LgpDeXitOPqXakj/D2T\nm7mMoXF1HOYObqdOc/5Qs1vvaW9RLHT6RuBvOPjzO8BGdXQzEu8EToNOJCBwcfZ6\nT1XRr6PEWtZOPFpDoaS7V1JCXgfjvqZN7O0i2WoaswKBgGDm/AWxfxyPMpjvS0q+\nxNbUQj063q+8Sc9/Vu/5j8Rp7CfZBjAOlxpO8z2WsyNdS12ubL7yK3dY4wVNWV9J\ntMN9zpiKWCq787dLnN/m+KA5WSroY2umDw1HUEymEjxh4N0Ib1k5ArfT9Dl0kSJG\nKGS1wkh34a4kx4r90IUfPL4L",
method:"POST",
success: function(){
alert('Load was performed.');
}
});
but itsnot working
Related
I have ajax call and pull the data and I want to send the response to next page in ajax success and get the data in drilldown.html
$.ajax({
type: "POST",
url: "drilldown.php",
data:data,
success: function(response){
window.location.href = 'drilldown.php'; // want to post the data this in redirection
}
});
If there is no server-side involved, you can save the data using
Window.localStorage (check if browser compatibility is OK for you)
$.ajax({
type: "POST",
url: "drilldown.html",
data:data,
success: function(response){
localStorage.setItem('myData', data);
window.location.href = 'drilldown.html'; // want to post the data this in redirection
}
});
On the drilldown.html page, you can read the data with JavaScript by
var data = localStorage.getItem('myData');
There's also sessionStorage which will be cleaned up after browser restart.
I'm making a simple ajax call as the following;
var getPrevious = function(){
console.log('ajaxing');
$.ajax({
type: 'GET',
dataType: "json",
url: 'http://'+DOMAIN+'/previous',
success: function(data){
console.log(data);
}
});
}
Whenever I run this function it's not returning success. What am I doing wrong; here's the url I'm trying to get the json data from; http://107.174.82.43:3001/previous
I'm new to making calls using $.ajax but it seems pretty straight forward, although I have no idea what I'm doing wrong.
To debug it, use error option
var getPrevious = function(){
console.log('ajaxing');
$.ajax({
type: 'GET',
dataType: "json",
url: 'http://'+DOMAIN+'/previous',
success: function(data){
console.log(data);
},
error: function(err){
console.error(err);
}
});
}
If you are running your app on a different from provided domain/port host, than you will face CORS issue. Your should host your js app either on same domain as your back api, or add js app domain to back-end whitelist.
Is it possible to send the cross domain URL request and read the response using JSONP?
Could you please give me some samples?
I am trying to send URL request to a different domain using xhr but couldn't read the response
Please help
Thanks in Advance
You can check with blow example:
$(document).ready(function(){
$.ajax({ // ajax call starts
//crossOrigin: true,
type: "GET",
url: 'http://www.google.com', // JQuery loads areas
dataType: 'json', // Choosing a JSON datatype
async: false,
success: function(data) // Variable data contains the data we get from serverside
{
console.log(data);
}
});
});
i am try to get data from web service ,, the web service is
http://www.webservicex.net/country.asmx?op=GetCountries
i am use the suds.js
how to get the data from the web service or how to call web service without send parameters or please help me in anything
$.ajax({
url: "http://www.webservicex.net/country.asmx?op=GetCountries",
type: 'POST',
dataType: 'xml',
success: function (xmldata, textStatus, XMLHttpRequest) {
//Do your thing! For instance:
console.log(xmldata);
}
});
I am trying to use JQuery to access Transloc's API (https://www.mashape.com/transloc/openapi-1-2#!documentation). I have not used JQuery or this API before. If anyone could shed some light on this I would appreciate it.
I can't test this as I don't have a key but it should work in theory.
Using the endpoint you linked to. Change the url for what you need.
$.ajax({
type:"GET",
beforeSend: function (request)
{
request.setRequestHeader("X-Mashape-Authorization", <mashape-key>);
},
url: "https://transloc-api-1-2.p.mashape.com/agencies.json?agencies=12%2C16&geo_area=35.80176%2C-78.64347%7C35.78061%2C-78.68218&callback=call",
processData: false,
success: function(data) {
//use data
},
error: function(data) {
//handle error
}
});