how to send jsonp request to server in sencha 2.0 - sencha-touch

I will get this error Repeatedly
Uncaught SyntaxError: Unexpected token : ajax.php
{"error":"Server Error</b>: Method file_get_contents unable to open request body!"}
Ext.data.JsonP.request({
url: 'http://yaksee.com/facebook/ajax.php',
callbackKey: 'callback',
params: {
format: 'json',
},
success: function(result) {
if (result) {
alert('success');
alert(result);
} else {
Ext.Msg.alert('Error', 'There was an error retrieving the weather.');
}
}
});
}},

You Have to disable the Browser's web security
Then it will be ok

Check out the example which works : http://docs.sencha.com/touch/2.1.1/#!/api/Ext.data.JsonP
I changed it to your URL and it stopped working in this fiddle so it seems like issue with webservice or it requires some more data to make request because it is returning HTTP 200 status but with some custom error message

Related

No Host in request URL for Grafana datasource plugin tutorial - Add authentication

I'm trying to follow the example for developing a datasource plugin from Grafana. Ultimately I want my plugin to use Oauth, but even with just the basic Grafana datasource proxy example I seem to be having issues.
I have updated my plugin.json, class and constructor.
I have setup this hard coded example.
in plugin.json
{
"path": "grafana",
"url": "https://github.com"
}
],
And a sample testDataSource()
async testDatasource() {
return getBackendSrv()
.datasourceRequest({
url: this.url + '/grafana/grafana',
method: 'GET',
})
.then(response => {
if (response.status === 200) {
return { status: 'success', message: 'Data source is working', title: 'Success' };
} else {
return { status: 'failure', message: 'Data source is not working: ' + response.status, title: 'Failure' };
}
});
}
When I try and save/test this datasource to call that method, I get in the frontend a
HTTP Error Bad Gateway
And in the logs
t=2021-09-17T14:31:22+0000 lvl=eror msg="Data proxy error" logger=data-proxy-log userId=1 orgId=1 uname=admin path=/api/datasources/proxy/9/grafana/grafana remote_addr=172.17.0.1 referer=http://localhost:3000/datasources/edit/9/ error="http: proxy error: http: no Host in request URL"
I would've expected the request to be routed to the datasource proxy and for that to make the request to github but it seems Grafana is making a request to /api/datasources/proxy/9/grafana/grafana and nothing is picking it up?
Looking up my datasource via API, there's nothing listed for URL.
You will need to render this in your ConfigEditor.tsx
<DataSourceHttpSettings
defaultUrl="http://localhost:8080"
dataSourceConfig={options}
onChange={onOptionsChange}
/>
Which will give you the basic form with URL, whitelist, auth options that you see on most plugins. The URL there I guess should match what you have in your routes.

VueJS POST http://127.0.0.1:8000/login 404 (Not Found)

so i post this qs yesterday enter link description here
i was getting this **Uncaught (in promise) Error: Request failed with status code 405 VUEJS
**
now i did fix the part of axios from this :
axios.post('http://127.0.0.1:8000/?#/login/',{
email: this.email, password: this.password
}, headers)
.then((response)=>{
const data=response.data;
console.log(data);
})
to this
axios({
method: "post",
url: "/api/login/",
data: {
email: "",
password: ""
}
}).then(
response => {
console.log(response);
},
error => {
console.log(error);
}
);
now i'm getting this error
as u can see the problem and the api.php and the root
405 error code means your api endpoint not allow the current method you requesting to so 405 errorbis aboutbendpoint problems, and about 404 response status in axios if server's response have a 4XX status it'll go directlly on catch it should be somthing like this:
axios.post("http://127.0.0.1:8000/api/login/",{data: value,data1: value1})
.then((res)=>console.log(res))
.catch((err)=>{
// 404 will be loged below
console.log(err.response.status)
console.log(err.response)
}
i have never saw somting like this but i think you should ckeck your api server and make sure you entered the currect url and currect port and make sure in your server logic response part you have'nt a type error or somithing im really sorry if it was'nt helpful
p.s. i wrote the code above with my phone im really sorry its may be a little ugly
and if you have some problems with your api server and your not a backend i can fix it(if its django) or i can make a simple one for you to use

Getting a 422 Authorization error with Uber API

I am testing my app for the first time, just trying to get basic info via the API but am getting an error: 422 Unprocessable Entity, "validation_failed".
What am I missing here? I have tried it with both sandbox-api.uber.com and with api.uber.com.
getting back:
code: "validation_failed" fields: {start_longitude:Required,
start_latitude:Required} start_latitude: "Required" start_longitude:
"Required" message: "Invalid request"
var uberServerToken = "XXXXXXXXcEE0cHbwhKiF_sl_ZUYvEHHO_f6U6dr" ;
$http({
url: "https://api.uber.com/v1/estimates/time" ,
headers: {
Authorization: "Token " + uberServerToken
},
data: {
start_latitude: setLat,
start_longitude: setLon
},
success: function(result) {
console.log(result);
}
});
You need to provide an access token for the request. Grab the access code from the user, exchange that for an access_token, and provide the access_token with each request to Uber's API.
Link: https://developer.uber.com/v1/auth/

Crossdomain jQuery ajax request was not called and give error status "parsererror"

I am trying to call cross domain url. which has response text as below.and it is valid json response.
[{"LANG_CODE":"UK_EN","COU_ISO_CODE":"BGR"},
{"LANG_CODE":"UK_EN","COU_ISO_CODE":"HUN"},
{"LANG_CODE":"UK_EN","COU_ISO_CODE":"PRT"},
{"LANG_CODE":"UK_EN","COU_ISO_CODE":"UGA"}]
Jquery ajax code which i am using for calling cross.
$.ajax({
url: "http://someDomainName/restfulservice/Api/Countries/Get_Json",
dataType: 'jsonp',
crossDomain: true,
async: false,
success: function (data) {
alert("success >> "+data);
},
error: function (jqXHR, textStatus, errorThrown) {
alert("error : "+errorThrown + ", textStatus >> "+textStatus);
}
});
every time it goes to error block. when i inspect this service in browser then it gives response text with valid json string.but through code i am getting error "jQuery18305917718204907095_1409810925309 was not called, status: parsererror".
while this code is working for the url "http://api.geonames.org/findNearbyPlaceNameJSON?lat=47.3&lng=9&username=demo".
what could be the issue for same ?
It is sending back JSON but you have said dataType: 'jsonp'. JSON is not JSONP.
Either change the service to support JSONP or change the client to expect JSON (which might require you to find some other way to circumvent the same origin policy)

Callback not getting called on Internet Explorer for Ajax JSONP call

I'm making an Ajax call using JSONP to fetch JSON data from a third-party (domain different from my site) and its working on Chrome and Firefox but failing on IE (9 & 10 are the versions I have tried). In the IE debugger I see the call is completing (with Http 200) but the callback I've specified for the JSONP call is not being invoked.
My code looks like this:
$.ajax({
url: 'http://api.yipit.com/v1/deals/?key=mykey&division=seattle&limit=1000',
dataType: 'jsonp',
contentType: "text/javascript",
async: false,
cache: false,
crossDomain: true,
jsonp: 'callback',
jsonpCallback: 'processResult',
error: function (xhr, textStatus, error) {
window.alert(error);
},
success: function (data) {
window.alert(JSON.stringify(data));
_yipit_deals = data.response.deals;
}
});
And the response body looks like this:
<html><body><pre>processResult({
... [valid JSON data]
});</pre></body></html>
When the call is made, the error function is getting invoked with error as: Error: processResult was not called and the IE debugger shows a script error caused when trying to parse the <html><body><pre> tags in the response. When running on Chrome and Firefox these html tags don't exist in the response body and I'm not sure why the response is different in the case of IE.
It appears that these tags are causing IE to barf and not be able to invoke the callback. I've tried specifying other values for contentType such as "text/html", "text", "application/javascript" and even not specifying it at all, but its not made any difference. I'm using JSONP to get around the cross-domain issue.
Any ideas? Thanks!
You have to pass an explicit format argument to the URL:
&format=json
Otherwise, it's just pretty-printing the output:
<html><body><pre>{
"meta": {
"code": 401,
"message": "Key not recognized",
"name": "AuthenticationFailed"
},
"response": {}
}</pre></body></html>
Also, I would set async back to true.