I tried to get response data using ajax from the below url
http://recipesid.appspot.com/api.user?method=user.query&email=dam.le#anttek.com
But it will not run anyway.
Help me to solve the issue
$.ajax({
type: "GET", //rest Type
dataType: 'jsonp', //mispelled
url: "http://recipesid.appspot.com/api.user?method=user.query&email=dam.le#anttek.com",
async: false,
contentType: "application/json; charset=UTF-8",
success: function (msg) {
alert(msg);
},
error:
function(data){
alert("error");
} });
Thanks in advance !!
Thanks for all answers. but i got a solution.
I must allow "Access-Control-Allow-Origin" in my google app engine.
Related
Usage of JSON.stringify() breaks page without errors in console
EDIT: I read about jquery plugin jquery-json, I tried that with the same result.
var bookmarkParams = {"id":"123456"};
$.ajax({
url: 'http://service',
cache: false,
type: "POST",
dataType: "json",
headers: {
// some headers
},
contentType: 'application/json; charset=UTF-8',
data: JSON.stringify(bookmarkParams),
success: successCallback,
error: errorCallback
});
// successCallback & errorCallback are defined functions
any ideas why this might be?
If i don't use JSON.stringify() then the page does not break but my AJAX request won't function correctly when passing my data to the server.
What is params? Don't you mean bookmark params?
try this...
var bookmarkParams = '{"id":"123456"}';
then change params to bookmarkParams
I have a problem with my code and i can't get it to work.
The request should go to my main domain, grab the version number and post it on the application but this does not happen.
Code:
$.ajax({
url: 'http://maindomain.com/dbstruk/version',
dataType: 'jsonp',
jsonp: 'callback',
jsonpCallback: 'jsonpCallbackSPP',
success: function(data){
$('#latest-version').text(data.version/100);
}
});
The location: maindomain.com/dbstruk/version contains only one line:
{"version":"105"}
Am i overseeing something?
Thank you.
I need to decode a data url in PHP .This data url is obtained via ajax.
I have used file reader to get the encoded data URL of an image.This data URL is passed to PHP via ajax:
$.ajax({
url: app,
async: false,
type:"POST",
data : "file="+strGlobalImageData,
dataType: "jsonp",
contentType: 'application/x-www-form-urlencoded',
processData:false,
jsonp: "jsoncallback",
success: function(html){
alert("Thank you. We will be in touch with you");
},
error: function(){
alert("Thank you. We will be in touch with you");
}
});
How will I do this?
$image =$_POST['file'] ;
Was this something you were looking for? Let me know
I am trying to call my service from here
http://diningphilospher.azurewebsites.net/api/dining
using below javascript,
$.ajax(
{
type: "GET",
dataType: "json",
url: "http://diningphilospher.azurewebsites.net/api/dining/",
success: function (data)
{
alert(data);
}
});
But I am getting error relating cross origin. I see people suggest using JSONP but I guess my server does not support JSONP. I studied CORS and could not understand the head or tail of it. I would like to know the way around to read the JSON that sits in different domain.
I hope this should work:
$.ajax(
{
type: "GET",
dataType: "jsonp",
url: "http://diningphilospher.azurewebsites.net/api/dining/",
success: function (data)
{
alert(data);
}
});
Or just add/append ?callback=? along with your cross-domain url.
I have a working ASP.Net test web service, but I keep getting 500 errors as:
"System.InvalidOperationException: Request format is invalid: text/xml.
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
"
when I call it with javascript.
It is a simple web service that takes a single parameter as a string and returns it to the client. Please help!
link to code here
For those of you who this might help, the issue was setting the SOAPAction in teh header correctly:
$.ajax({
type: "post",
url: target,
contentType: "text/xml",
data: soapBody,
dataType: "xml",
processData: false,
beforeSend: function( xhr ){
xhr.setRequestHeader(
"SOAPAction",
"http://blahblah.com/Services/MethodName"
);
},
....
Make sure that your mess variable doesn't contain GET-style query string like '?a=1&b=2'. You need to send it in POST format, for example in JSON. Try to change contentType to contentType: "application/json; charset=utf-8"
$.ajax({
url: service,
type: "POST",
dataType: "xml",
data: '{key: value}',
complete: endTest,
error: processError,
contentType: "application/json; charset=utf-8",
});