Skip to main content

Posts

how to remove a ul li by id after a ajax call to delete a MySQL row? not sure where in the i put (#liid).remove with jquery

I have a app that shows list of income items where each item is inside a li with a id= "number,item description and little trash icon inside the li. so far i have a code that calls a ajax when the user clicks the trash icon that removes the mysql row using a php script called by ajax, however i am not able to remove the li with a unique id without refreshing the page when i click on trash icon this is a piece of the code that i have so far <ul> <?php $sqlinc = "SELECT * FROM transactions WHERE username = '$username' AND transaction = 'income'"; $resultinc = mysqli_query($conn, $sqlinc); if (mysqli_num_rows($resultinc) > 0) { // output data of each row while($rowinc = mysqli_fetch_assoc($resultinc)) { echo '<li class="delli" id="'.$rowinc['id'].'"> <button id="" class="fl delbutton" onclick="">'. $rowinc['memo'].'</button&

Form submits instead of displaying error when button is clicked

I have made a form as index.html. I have a from validation using JavaScript. When the submit button is clicked it must open another html page(detail.html). When I supply wrong data, it must prevent the opening of detail.html page and display the error messages but neither of them happens . here is the code <form action="/detail" method="POST" role="form" name="index" onsubmit="return validateForm()" enctype="application/x-www-form-urlencoded"> <label for="name">Name</label> <input type="text" name="name" placeholder="Enter your name" required/> <span class="formerror"></span> <br /> <label for="phone_number">Mobile:</label> <input type="number" name="phone_number" placeholder="enter your mobile number" required > <span class="formerror"&

The code block below execute before my async await finishes

const getGroup = async (req, res) => { const { id } = req.params try { const group = await Group.findOne({ _id: id }); const groupNotesPromise = await group.group_notes.map( async (fileId) => { const file = await File.findById(fileId) return file; }) const groupNotes = await groupNotesPromise.map( async (notePromise) => { await notePromise.then(res => console.log(res)) }) console.log(groupNotes) } catch (error) { console.log(err.message); res.status(400).json({ err: err.message }); } } Hello guys, I have a function above, this is retrieving data from MongoDB. However, I would like to know why would my console.log(groupNotes) be printed before the execution of the groupNotesPromise.map above, as it has an await in the function. Below is the console.log(groupNotes) and console.log(res) from the code above [ Promise { <pending> }, Promise { <pending> } ] { _id: new ObjectId("6496c645bf2bb

Loading nodes CSV to AGE with provided IDs returns "label_id must be 1 ... 65535"

I have a csv file that is not formatted in the correct way for AGE to load. I was on the task to transform it into a new one so that AGE could read it and create nodes, like it is specified in the documentation . For that, I created a python script that creates a new file, connects to postgres, and performs the queries. I though this could be useful since if someone had csv files and wanted to create nodes and edges and send it to AGE, but it was not in the specified format, this could be used to quickly solve the problem. Here is the old csv file (ProductsData.csv), it contains the data of products that have been purchased by other users (identified by their user_id ), the store where the product was purchased from (identified by their store_id ), and also the product_id , which is the id of the node: product_name,price,description,store_id,user_id,product_id iPhone 12,999,"Apple iPhone 12 - 64GB, Space Gray",1234,1001,123 Samsung Galaxy S21,899,"Samsung Galaxy S21 -

How to add and multiply arguments? [closed]

I'm trying to make it so it will add or multiply based on if the result is over or under 1000. Sorry if my coding is atrocious. I'm still very new to this. def multi_sol(*num): product1 = 1 for i in num: if product1 <= 1000: product1 *= i return product1 else: for i in num: if product >= 1000: product1 += i return product1 result = multi_sol(20, 50) print("The result is", result) source https://stackoverflow.com/questions/76551947/how-to-add-and-multiply-arguments

How to use YAML to create a common node between two functions in Apache Age?

have two Python functions that each create a Person node in an Apache Age graph. I want to create a common Person node between these two functions that has the same properties. I've been told that YAML can be used to define a common configuration file that can be included in both functions to create or update the common Person node. My question is: How can I use YAML to define a common configuration file that can be used to create or update a common Person node between my two functions in Apache Age? Specifically, how do I load the YAML file into a Python dictionary, and how do I use the dictionary to set the properties of the Person node in my Apache Age graph? Here's an example YAML configuration file that defines a common Person node with a name property: Copy common_person: name: John Doe And here's an example function that creates or updates the Person node in Apache Age using the common_config dictionary: from age import Graph def update_person_node(common_config

Is there any way to make an API within the same URL of React.js application just like Next.js?

In Next.js, I can access my application on localhost:3000 , and access to my API from localhost:3000/api/hello . Is there any way to do this by using React.js and some other framework like Express.js? What is the solution if I don't want to use Next.js? Both on development and production. EDIT: In production: I just deployed my express.js app to my shared hosting using app.listen() and it works fine because in production we don't or we shouldn't specify the port as I know. So there's no need to worry about ports being different just because they are in development. In develoment: I haven't tried anything yet but as jcubic mentioned maybe we need a proxy. Via Active questions tagged javascript - Stack Overflow https://ift.tt/qGvtTKg