Dynamic Dropdown Menu Rendering [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am very familiar with programming, MySQL, PHP, JavaScript, jQuery, HTML and CSS, and this issue of mine has nothing to do with what I just mentioned. It all boils down to three things:
Defining a menu layout with link options.
Rendering a dropdown menu on-demand with position calculated live.
Determining if the current user with current session is owner of the object clicked.
Nr. 2 is not a big problem, very simple indeed. Nr.1 & 3 are a bit problematic. And it is this part that I do not fully understand, I know that for Nr. 3 Ajax can be used to communicate with the PHP in the backend and determine ownership of an object through IDs.
As for Nr.1 should this be put in PHP or as a JavaScript AMD definition, I am not so sure about this myself.
I hope things are much clearer now.

Yes it is. Ajax can be used to load any data (html also) it depends on the programmer that what he wants to do with the data. For example, if you send a request to server to send some html, and in response it sends HTML to you then you can just simply render that html code in your DOM. It is as simple as that...

It actually depends on the requirement that you should use an ajax call or just use jquery to append or show some html.
(For simplicity and for your question):
Use Ajax:
To get data from server.
Append html using ajax if the html contains the data which needs to be get from the server.
Use Jquery:
To append/show html which is present on page ,no need of ajax call.
Like for example in above quora dropdown ,
-There is no ajax when you click on that "..." image(Although you can use ajax here but it depends on the application requirement,here quora is getting this drpdown values on page load).
-There is ajax when you click on "Make anonymuous" ,"Add to reading list" etc etc.

Related

the code of some page is cut when using curl or display the source code of the page [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I explain my problem to you:
When I do PHP curls on some site or want to display the source code of the page element is missing a lot. I think some part is called by a script or something. Could someone help me view the entire code with Curl PHP.
To duplicate my problem go to Facebook or LinkedIn and right click on the page and "View the source code of the page", in this you don't see all the page content but when for example you right click and "inspect an element" You can.
Thank you in advance
CURL can't do this. It's not designed to render HTML or execute JavaScript.
A lot of the content on Facebook, LinkedIn, Twitter and many other pages is loaded through different ways. (like fetch()-requests or WebSocket-Events)
Some nodes you can see in the inspector are not part of the original document (which you are viewing with "view source" or curl downloads). What you see on the inspector is everything currently held in memory, which was partially (or completely) created with a scripting language.
This is basically done to
reduce the load on servers as it doesn't have to generate the whole page on every request
reduce traffic on clients and servers (no need to reload the header-data and/or scripts over and over again)
If you need data from a rendered site, you should either check if the website provides an API which gives you the data you are looking for or use one of the cli-rendering-engines from this answer.

Save created div to database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
User creates new element/node (div) via javascript on click of a button. The new element is saved as "part" of the page through sql.
I dont need a solution, I just need a starting-point. If known, then best practices.
Need better search terms. Thats all.
NB. What I'm finding is how to save the content of the div to sql. That I know. As well as how to create new elements. I suspect its done through fx ID and looping. But I'm not being precise enough when searching.
As a starting point, you're going to need to learn AJAX.
Then, you'll need to extract the contents of a div and send it back to the PHP which will put in your database. Given that it seems you're a novice, I recommend using jQuery to do this.
So, as a starting point, to extract the contents of a div using jQuery do the following:
//Let's say your div is as follows:
<div id="some_div">Here you have some content</div>
//Here's the jQuery to extract the contents:
var divText = $("#some_div").html();
From there, you'll need to use AJAX to send it to PHP to write it to your database. It should be noted that if they're creating a NEW div, you'll need to reference an existing div on the page first and then the created div as a child of that because you're inserting something in to the DOM that wasn't already there and your Javascript won't be aware of it. So you'll have to learn about "delegation" also.
It sounds like a lot to learn but we all have to start somewhere.

Store contents of a <div> to another webpage [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want my users to be able to view content on my website, and when they see content they like (My website randomly generates content using JQuery.load() ), I would like them to be able to store it onto a personal page that they have to log in to, to see.
My page loads content with the line:
$(".resultContent").load(skillList[skillChoice]);
The variable "SkillList" is assigned "skills.html #id"
the '#id' part is identifying a <div>, and that's the part I want to be stored, and I want the user to be able to store multiple parts of the page skills.html on their personal page.
This sounds fairly complex, but I was wondering if it's doable, if so, what language(s) would I need to use?
You will need to save those html snippet on the server, mostly likely in a database. This can be done by client-side javascript, an ajax POST. The server side can use any language.
Since you are saving some html on the server and will load that in a page. The server side must sanitize the html snippets for security.
When the html snippet is saved, the server needs to know who sends the request. That is the user needs to log in before or when s/he saves the content for later use.

Browsing a database as the user is typing [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
This is probably a simple question, but I'm struggling with this.
Basically, how to browse in a database, as the user is typing something?
For example, in a website such as https://www.doesthedogdie.com/, how do they do it to show all the movies beggining with the string of characters you're typing, as you're typing it?
I guess javascript is involved?
It's called autocomplete
Please do some googling next time yourself.
You can use jQuery autocomplete or Bootstrap typeahead to achieve this.
Hope this helps
My personal preference on how to make these kind of systems is fairly awkward, yet it seems to work just fine for me without requiring too much client-side scripting.I use ASP.NET's Page_Load event to save all content in a SQL database into an XML file. Then, when the user enters some text into the field, I make a hidden div class underneath it unhidden to display filtered results from the XML document. This way, you can update the SQL database at any time fairly simply to add new records which should be listed on the website.This is server-side scripting, which I prefer to client-side because the user can disable features and mess around with it to view your code which is something I personally hate.I hope this helps you somewhat.

asp.net mvc a grid of results with close buttons [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Currently converting an old asp.net web forms page into a asp.net mvc version, and a little stuck on something that isn't a major deal, but would be a nice to have.
When the user logs in, they are taken to a messages page at /Alerts. They can close individual messages by clicking the x's, and then if they close all the message they are moved onto another page automatically.
The original site did postbacks, so the URL stayed the same. In my new version, I planned to make the x button a link, that went to /Alerts/Confirm/xx where xx is the id. The problem is, after processing, the address bar stays on that url, whereas I'd like to leave it on /Alerts
The four solutions appear to be either:
1) using AJAX to do the processing;
2) a redirect back to /Alerts after processing;
3) replacing all the X links with a submit button, and using javascript to pass a different ID depending on which message is being acknowledged, so that I can change the Confirm method to an HttpPost-accepting Index method?
4) URL Rewrites? (not sure about this, just thought of as I wrote this)
Or am I missing something obvious that would do what I'm trying to achieve?
I agree with #1 and use Jquery to do it.
Or you could show/hide those messages using Jquery .show() .hide(). So, they would always be there, just hidden. When they hit refresh they would show again.
You can also use some sort of notification plugin for jquery, there are many available just google for it, this page has about 6 examples, it is a bit old but you can get an idea.

Categories