I have this URL: http://localhost:.../home/blogpost/#'I want to get this string'
I get it when pressing:
#item.Title
#item.Title is from my database and that string will change. Now I need to get the 'I want to get this string' string on that page so that I can do a if statement with it, like this:
#if(#item.Title == 'I want to get this string')
Any suggestions?
The target attribute (the part of an URI after the #) is not sent to the server when the browser retrieves the page. So, you cannot get it out of a normal GET or POST request on the server at all.
That data is available in the browser, so you could access it using javascript of even CSS.
Using ajax techniques, you could load a skeleton page and send the target string yourself to the server and have it react to it, and only then load the rest of the page. A bit overkill for most uses I'm afraid and there are drawbacks as well (e.g. search engine might have more trouble to see your content).
It's easier to send the string to the server as a GET parameter if you have the level of control you seem to have. [simply replace the # with a ?], that will be sent to the server by the browser.
Do note that you should URLencode any data you add on to a URL ...
Related
I have a page html let's call it abc.html
There are AngularJS fields embedded in it.
I am now writing a GET and POST in scala which routes the fuzzy search arguments to the proper page on the server.
I am trying to understand the sequence in which things occur in order to implement a GET/POST requests (written in scala) which would happen when someone makes a search on the search bar on the abc.html page, and which would return elements from the database
Is it abc.html (search) --> http GET request --> backend ( AngularJS) --> Database?
In this case this would mean my http post or get request would pass in the html data model elements which would in turn hit the backend AngularJS controller page which in turn would hit the database, and the return ride would send the database results via an http request to the page?
Do I need to explicitly define my GET in terms of angular fields and the database model?
thanks
HTTP uses request-response pairs. This means you don't have to make another request to return anything to the client, you just need to write the proper response. Other than that, your idea is fundamentally right. The process would look something like this:
Type something into the search form on your HTML page
Submit the search form to your backend. This creates a GET or POST request depending on your form element's method attribute.
(At this point the browser is awaiting a response)
As the request reaches the server, your backend code can capture its data and make a query to your database.
(At this point the server is awaiting data from the database)
The database returns its results, your backend code is free to format it into a response to the client's original request.
The client receives the response and you can use your frontend code to display it to the user.
What I have: Apache Solr 5.2.1
What I want: add a new document in a specific core defined by me
example: address of the solr core -->
http://IP_ADDRESS:8984/solr/myCustom_core/
I want to add a document json formed by {"id":"00001","title":"my title"} to the core above directly from the browser's url bar.
Problem:
I'm trying to address this problem in such a way:
http://IP_ADDRESS:8984/solr/myCustom_core/update?wt=json&{add:{"id":"00001","title":"my title"}}&commit=true
The response of the browser is:
{"responseHeader":{"status":0,"QTime":88}}
However, when I check on the server side the new entry is not added.
Conversely,it is works if I try to add such a document using the submit command provided in the UI of Solr.
Can someone provide me the correct way to build the correct url address?
Thanks
EDIT: thanks to MatsLindh I solved my problem using this:
http://IP_ADDRESS:PORT/solr/myCustom_core/update?stream.body=<add><doc><field name="exampleField">example value</field></doc></add>&commit=true
You can use stream.body to send an arbitrary content stream through GET variables instead of using POST (or a regular body).
Be sure to perform appropriate escaping of the content you use in your URL.
You'll also have to perform a commit before the submitted content becomes searchable, either through commit=true in the request or by issuing a separate commit request.
I am attempting to connect to a DB on Cloudant. I created the DB from a JSON and uploaded it to Cloudant here: DeanRadar
I copied the info byte for byte into another JSON on my server including the "_id" and "_rev". If I call the JSON directly it works fine, but I can not get the code to work when I enter the URL given above.
I am guessing the URL is just a place holder and it gets resolved before returning it to my browser, like it is supposed to have a ".json" on the end of it or something that the browser can read but not the code. I do not know enough about Cloudant, Couch, angular, etc to know what I am looking for. I have done plenty of PHP/SQL databases but this is my first attempt with cloudant/jason/angular.
Here is the code in question (ignore the fact that I declare dbURL twice, it is there to show what I have used)
var dbURL = 'https://deanradar.cloudant.com/tempdata/80d7d28d9e96778ad3bf4531817ab190';
var dbURL = 'data/tempData.json';
$http.get(dbURL).success(function(data) {
tempDataDeferred.resolve(data);
});
This works, when I access the JSON on my server copied from the cloudant DB, but swapping the dbURL lines (accessing the direct URL for the cloudant DB) returns nothing. You can take that same URL and slap it into your browser address bar and see the info exactly as it sits in the JSON.
Grabbing the "[API URL+]" address doesn't help, it won't even resolve in the browser. Any idea what I need to do to access the DB?
Check this document
https://cloudant.com/for-developers/crud/#browser-update
although in examples they are using jquery.couch you can check the original code and apply it to your angularjs app
I can already use jQuery.post to send JSON data to the server, but I can't find a way to have the response replace my current page just as a regular old POST would when using plain HTML.
The only way I know right now to come close is to create a dummy form, add the JSON data as a value, then trigger submit. This seems like a big hack and also requires the server side to know where to look for this value (whereas it automatically detects JSON when jQuery sends it).
Please tell me there's a better way!
Example desired usage (note that I don't want the data encoded in the URL):
magic_load_page('/page', {'foo':'bar', 'list':[1,4,9,16]}); // uses POST request
There is a web service that allows me to go to a URL, with my API-key, and request a page of data. The data is returned as JSON. The JSON is well-formed, I ran it through JSONLint and confirmed its OK.
What I would like to do is retrieve the JSON data from within MS Access (2003 or 2007), if possible, and build a table from that data (first time thru), then append/update the table on subsequent calls to that URL. I would settle for "pre-step" where I retrieve this information via another means. Since I have an API key in the URL, I do not want to do this server-side. I would like to keep it all within Access, run it on my PC at home (its for personal use anyway).
If I have to use another step before the database load then Javascript? But I dont know that very well. I dont even really know what JSON is other than what I have read in Wikipedia. The URL looks similar to:
http://www.SomeWebService.com/MyAPIKey?p=1&s=50
where: p = page number
s = records per page
Access DB is a JavaScript Lib for MS Access, quick page search says they play nicely with JSON, and you can input/output with. boo-ya.
http://www.accessdb.org/
EDIT:
dead url; wayback machine ftw:
http://web.archive.org/web/20131007143335/http://www.accessdb.org/
also sourceforge
http://sourceforge.net/projects/accessdb/