1

Just an idea. Rather than trying to do two things at once, first make one work then (when you're sure the first bit is correct) concentrate on the second.

If you can't answer the question of "which part is broken?" you're going to struggle.

Install httpie and then you can test your API simply from the command line:

http post localhost:4567 < payload.json

where payload.json contains

{
    "profile_info": "Hello world"
};

Once that works, then re-create that POST using jQuery's $.ajax(). The benefit of working this way is that if something doesn't work, you know exactly where the problem is.

Votes + Comments
I fall down if I move both legs at the same time, unless I'm jumping?
0

A few points.

You are looping through dutyStatusLogs multiple times in different ways. You're calling dutyStatusLogs.forEach twice and $.each(dutyStatusLogs, function(i,v){...}) once. These should probably be combined into one loop.

Now, what your original question was about, the nested loop

        $.each(dutyStatusLogs, function(index, value) {

                    var json = dutyStatusLogs;

                        var tr;
               for (var i = 0; i < json.length; i++) {
               }

This section doesn't look right to me. You don't appear to be using the outer loop for anything (there are no references to index or value inside the $.each loop), and you're executing the inner loop once per iteration.

I would rewrite that section in the following manner:

$.each(dutyStatusLogs, function(index, dsl) {
    var dateFieldValue = dsl.dateTime;
    var employeeNo = dsl.driver.employeeNo ;
    var status = dsl.status;

    ...
});

Note I'm using variable dsl (for dutyStatusLog) instead of accessing the original array with the index, this is one of the benefts of using jQuery's $.each function. Newer JavaScript allows for an even simpler syntax. If that's an option you can make your code more readable by using it.

for (variable of iterable) {
  statement
};
0

Your for loop will be executed once per iteration of your $.each loop.

If that's what you intend to do, then it's not dangerous. Perhaps posting an example of your code (use jsfiddle or similar) would help you explain exacctly what your concerns are.

Additionally, the two types of loop can be used for the same purpose, they are just different syntax (there are other differences but let's not complicate things).

0

href="#" makes an anchor tag appear like a link without actually redirecting you. It's intended to take you to anchors on the same page (<a href="#section-1">Section One</a>) but with no following text does nothing.

The intention is that a JavaScript handler takes over the click event.

0

Not that it matters, but here it is in Ruby.

Simple, elegant and concise. Dare I say, beautiful?

lower, upper = 20, 400

lower.upto(upper)
    .select{|i| i.modulo(3).zero? && i.modulo(4).zero?}
    .each_slice(5){|m| puts m.join("  ")}

.upto loops from the called number to the arg. Normally I'd have written this (lower..upper).select… but this makes it a bit clearer.

.select returns an array containing elements where the block returns true.

.each_slice iterates through the enumerable object in chunks (the first arg, 5 in this case) and executes the block for each chunk (printing the array joined by two spaces).

1

Additionally, in theory your ISP could inspect your data as it passes through them on its way to you. However, sites that contain important personal data (such as your bank, email provider, online shops you buy things from, etc) should be secured via SSL. This will prevent anyone from inspecting data in transit.

Your browser will tell you if a site is secure, just look for a green padlock on the left side of the URL bar.

Screen_Shot_2017-11-10_at_15_57_10.png

It's a good idea not to send anything personal or important unless you can see one of these.

2

TinyMCE is open source and the 'community' (read: unsupported) edition is available using NPM, and easy to use with module loaders like webpack and browserify.

I'm guessing Davy hasn't done it that way, but without him saying what he's done it's impossible to point him in the right direction. The right direction is probably RTFM, though.

Votes + Comments
Yes. "What did you do, Dave?"
0

Incidentally, here's the portion of my API that handles CORS. It's in Go (with vestigo), but should be easily translateable to whatever platform you're working with:

    if config.CORSEnabled {

        Warning.Println("CORS is enabled, origin:", config.CORSOrigin)

        r.SetGlobalCors(&vestigo.CorsAccessControl{
            AllowOrigin:      []string{"*", config.CORSOrigin},
            AllowHeaders:     []string{"Authorization"},
            AllowCredentials: true,
            MaxAge:           3600 * time.Second,
        })

    }