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);
}
});
Related
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.
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/86riONbY2vTGsx9kxToruRqywzD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VVaLs/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
Please Help me,
I want to call a server side function in page1 from page2 using java script.
For example in Home.aspx.cs i have read() webmethod and i want to call this method from Call.aspx's Javascript function.
You need to create an ajax call:
$.ajax({
url: "linkToOtherPage",
method: "POST", // or GET, I don't know what you need
data: dataToPass,
success: function (response) { },
error: function(jqXHR, textStatus, errorThrown) { }
});
I made an application based on phone gap 2.9.1 android application with local database
with transaction and create query. but now i want to make remote database for this application so that i can use it from anywhere with same database. Can anyone help me? please..
Thanks..
Make a webservice. connect through it using ajax and parse json
Edited
I tried something like this (this is not web service though)
below is made from ASP.Net
[AllowCrossSiteJson]
public JsonResult AddPerson(Person person)
{
//Get Data here
return Json(*put something here*);
}
and called it in my javascript
function saveData(person) {
var json = $.toJSON(person); //converts person object to json
$.ajax({
url: "http://somedomain.com/Ajax/AddPerson",
type: 'POST',
dataType: 'json',
data: json,
contentType: 'application/json; charset=utf-8',
success: function (data) {
alert("ok");
}
});
}
Edited Part 2
You can do the same in PHP
I'm doing a project in Jquery Mobiles and need an webservice. Normally in android we have the http connection and we got the response as xml/json etc.. We parse the data and processed to the view. Here,In case of jquery , facing problem to solve the issue.. I read that ajax call is using for the webservices.
Sample code
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "some url",
data: "{}",
dataType: "json",
success: function (msg) {
alert(msg);
//$("#resultLog").html(msg);
}
});
Also,I refer the google api_Place Search, the service for this is entirely different
RefernceLink Click HERE!
Does anyone suggest the proper way to implement the webservice to interact with my server and retrieve the json response?
Thanks in Advance!