I'm looking to create a database which I can access without api keys using a link. Essentially, I"m looking to copy this exact system: http://gd.geobytes.com/AutoCompleteCity?callback=?&q=New except I'd like to replace the results with Airport codes and names which I have. Anyone have any idea how I can do this?
Maybe it will help if I clarify further. I am using typeahead and in my custom.js file I have the following which I need to update to use my own dataset but I"m clueless on how to do this.
$('.typeahead').typeahead({
hint: true,
highlight: true,
minLength: 3,
limit: 8
}, {
source: function(q, cb) {
return $.ajax({
dataType: 'json',
type: 'get',
url: 'http://gd.geobytes.com/AutoCompleteCity?callback=?&q=' + q,
chache: false,
success: function(data) {
var result = [];
$.each(data, function(index, val) {
result.push({
value: val
});
});
cb(result);
}
});
}
});
After your comments:
what you want to know are three questions assuming you are gonna work with php and mysql since is easy and basic way to start with web development (imho):
you need to know:
Tutorial of how to create a database with mysql
How to connect mysql with php
How to response a json with php
How to make a ajax request
to a php server with javascript
To be honest man this is a lot to learn and if you are starting with web development I totally suggest you going for the basic first. What you are trying to build at the end is a Restful system, there a lot of frameworks and ways to do this, via Web Api C#, or http://www.slimframework.com/
as example, but again you question is too abroad and not too clear, Im trying to help you because in one moment I started with all this questions, I googled for a tutorials in web development I hope some will work for you https://www.odesk.com/blog/2014/03/10-best-web-development-tutorials-beginners/
Related
Hello I need to display some data from an online JSON file to the frontend of my shopify store but however I do it I keep seeing the CORS error. Does anybody know how I can go about this in the correct way or a way around it?
This is a snippet of how I was trying to attempt it:
<script type="text/javascript" >
var url = 'text/javascript" src="https://******/admin/customers.json';
var j = [];
$.ajax({
type: 'GET',
url: url,
dataType: 'json',
success: function(data) { j = data;},
async: false
});
alert(j);
</script>
Wow. 14+ years of Shopify and still CORS questions. Obviously, you cannot call /admin from the front-end of your Shopify store. That would be silly as you need to then expose your API keys to the world, and that world is nasty. Someone could erase your shop or turn it into a fancy emporium selling peanuts in the shell for $10 each.
If you want to show off customer data to customers use Liquid. If you cannot figure out Liquid, and you must do callbacks to the /admin, you use an App, and a Proxy.
I have a downloaded CSV file which I would like to parse and use to create JSON objects for each record. The file is on my local machine but I have read that JavaScript has security measures in place that prevent access to these files.
Some examples show using csv.js with the following:
$.ajax({
url: "G:\downloaded_files\filename.csv",
aync: false,
success: function (csvd) {
csv_as_array = $.csv.toArrays(csvd);
},
dataType: "text",
complete: function () {
// use the array of arrays (variable csv_as_array)
// for further processing
}
});
When running this it just creates a GET request in the console. I am treading on unfamiliar territory here so any explanations would be great.
If I was to do this using Ruby I would do this, which hopefully will give you an indication of what I am trying to achieve:
require 'csv'
class FileRead
csv_text = File.read('/home/richardlewis/Downloads/csvtest.csv')
csv = CSV.parse(csv_text, headers: true)
csv.each do |row|
hash = row.to_hash
puts(hash)
end
end
I'm hoping this makes sense and someone can point me in the right direction.
You cannot call local files (from hard dics) using Ajax, or by any means from a web browser. You will have to publish your file using some sort of server. If you are using Linux you should have an Apache server already installed.
You need a REST service that will return your file in some format. JSON is the best, because it's easy to manipulate JSON data on the front-end.
It would look like this:
$.ajax({
url: "http://localhost:8080/services/rest/get_file", // your rest address
...
});
My boss asked me today if it is possible to use Sharepoint list data into an external HTML website...
The client have a sharepoint intranet and an HTML website.
They are publishing news on their sharepoint but they'd like to recover the news (sharepoint list) and put them into the home page of the other website.
I saw some different possibilities using Jquery or JavaScript or else Json.
To the effect that i'm not a regular with these languages...
First question: Is that possible? Because i think the two websites have differents servers.
Second one: if yes, how can i do that?
Thanks in advance
Hello and welcome to stackoverflow. A better place for your question might be over at https://sharepoint.stackexchange.com/.
Anyways, you can of course use a variety of methods to get sharepoint's list data - for example using the REST interface:
function getListItem(url, listname, id, complete, failure) {
$.ajax({
url: url + "/_api/web/lists/getbytitle('" + listname + "')/items(" + id + ")",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
complete(data);
},
error: function (data) {
failure(data);
}
});
}
}
Here's some more info:
http://msdn.microsoft.com/en-us/magazine/dn198245.aspx
Yes, that is very much possible. You can consume webservices in sharepoint to expose data.
If you other server is purely HTML then the only way would be to go with consuming web services via Jquery.
However, if its PHP/Ruby or some other server, you can consume the services in the server side language as well.
https://www.nothingbutsharepoint.com/sites/devwiki/articles/pages/got-rest-querying-sharepoint-list-data-using-rest-services-client-side-part-1.aspx
First off, apologies if this is a silly question, I'm new to WinJS and relatively new to Javascript, but I've been going great til I hit this roadblock.
I'm currently working on a weather app for Windows 8 using WinJS, and I'm trying to pull the data from the forecast.io API, which in my case is provided in JSONP format.
I easily got it working in-browser using jQuery and .getJSON, but since I have to use WinJS.xhr to request the data instead I'm having some difficulty.
I can pull the data just fine using the following code:
function getWeather() {
WinJS.xhr({
type: "GET",
url: "https://api.forecast.io/forecast/*ommited API key*/-36.044394,146.953718?callback=?&units=si",
headers: { "Content-type": "application/json" }
}).then(function complete(data) {
var weatherData = data.responseText;
(new Windows.UI.Popups.MessageDialog(weatherData, "Success!")).showAsync().done();
}, function error(data) {
(new Windows.UI.Popups.MessageDialog("Failed.", "Error")).showAsync().done();
});
}
This shows me the data in a popup window, so I'm sure that I've accessed it. The problem is, I can't do anything with it. In jQuery I simply used "data.currently.temperature" to get the current temperature data, but I can't get something similar working in this situation.
Any help or pointers would be greatly appreciated!
P.S sorry if I butchered any terminology, I'm doing my best.
Here's what data.responseText returns, there's quite a lot so I put it in a text file.
http://justadddesign.net/data.responseText.txt
It's because data.responseText is string not object. Try:
var forecastInfo = JSON.parse(data.responseText);
and then access forecastInfo object properties.
I am currently stuck on a task in which I have to use jQuery ajax to retrieve messages from PARSE HERE API to create something like this:
http://chatbuilder.hackreactor.com/?example=1&username=aa
I was wondering if anyone could explain to me how to use REST api to retrieve messages.
I have looked at other people's coding examples:
https://github.com/stevernator/Chatbuilder/blob/master/draft11
and
https://gist.github.com/guymorita/5726564
They seem to use ajax code like below:
$.ajax({
url: "https://api.parse.com/1/classes/chats",
dataType: "json",
success: function(data) {
var stuff = [];
for(i=0; i < 10; i++) {
stuff[i] = data.results[i].text
}
My question is: from where are the messages being generated from in this app? Do I have to create an account at Parse or would I just use ajax to retrieve this url link:"https://api.parse.com/1/classes/chats"?
Also, where would I find info on this specific class (chats)?
Any input would be greatly appreciated. Thanks!
The parse quick start guide is a very good place to start. The documentation is really good but the tutorials for the JS API are far more complex (backbone) than the documentation. I would download the Todos tutorial as there is some good stuff in it but if you dont know how backbone works its harder to read. I would have made this a comment but I don't have enough rep :(.