« first day  last day (14 days later) » 

12:00 AM
$.get( YOUR URL ,THE DATA , function(data, textStatus, jqXHR) {
 
Yeah, that alerts a lot of stuff your free host is pushing in your code for tracking on your site.
Maybe if we set the content type on the PHP code, try right after the first header with the Access-Control... to add header('Content-type: application/json');
That will tell the server it's not HTML we're viewing, but a response
Let me know when you've added that to the PHP
 
Done!
 
Let's check
Hmm, it's pushing the garbage anyway
Ok, we can just check the substring then. Keep the header for now
Ok
now inside the callback (which alerts data) I'd like you to use substring which you've used before on the data and grab the first 4 characters and alert those
Instead of the whole data
(Store it in a variable)
As always, let me know when you're done, or if you're stuck
 
12:12 AM
Uncaught SyntaxError: Unexpected token ;
You forgot to close the substring call ) :)
 
Please remove the header I told you to add earlier
As your host still produces invalid JSON, it'll have to do
 
which one?
 
(the content type one)
 
json one?
Done
 
12:15 AM
great :)
Now, what does it alert?
 
It should alert "Valid on the client side" "true" "NO" for valid emails that are not in the DB, and "Valid on the client side" "fals" "NO" for "test7@gmail.com"
 
fals, now "false
 
Yeah, but true will be true< :P
 
:(
what the heck!!!!!!!!
 
12:16 AM
Now, (assuming we return to substring(0,4))
 
Instead of passing false to the callback, let's pass data.substring(0,4) == "true"
We should get 'Valid on the client side' and 'TRUE' for anything but test7@gmail.com that is a valid email.
For test7@gmail.com , we'd get "Valid on the client side" and "false"
 
Now, let's show the error if there is one, and submit if there isn't any error :)
This means, checking if(isValid) and if it's not, showing an error, if it is calling form.submit()
 
test7@gmail.com gives me Valid on client side, fals, NO
@BenjaminGruenbaum ^
 
12:22 AM
That's good
it means it's valid on the client side, but not on the server side
Now, we want to submit the form if isValid is true :)
 
Oh ok
 
This is fully functional code, I've added a div with red color and ErrorMessage and I write stuff to it instead of alerting it
 
Works!
Let me see if I can integrate that with the original code
 
Well, I'm glad I could help
Coding is an incremental process
You break your bigger problems into smaller ones, identify sub tasks, and complete them
 
If you don't mind, could you just give me one second? It would be disastrous if you leave and then it halts in the middle again :D
 
12:26 AM
If you would have asked any of the smaller questions you've asked in this room, or the php room for that matter, you would have gotten instant help.
That's because any of the smaller questions were specific, focused questions.
All you need to do is break problems into sets of smaller ones, and solve those one at a time.
 
If we did all the code in JQuery, would it have been easier? Or would that have taken just as long?
 
Probably a little bit shorter, but nothing too segnificant
The problem is, jQuery is a black box
It does 'magic' for you, this code (at least) I hope you actually understand :)
- How do I check if a table in PHP contains a value
- How do I return response to AJAX from PHP
- How do I perform an AJAX request in JS to check something
- How do I prevent a form from submitting
- How do I submit a form programatically
- How do I check if a function submits in JavaScript
- How do I get the text of an input in JavaScript
- How do I declare a function in JavaScript
- What is `data` here, what purpose does it fill
All these are good questions who would have gotten an answer in either room
The important part is to identify these smaller questions and ask those, if you're not sure about the general design that's a good question.
"Why does my code not work" rarely gets a response, especially when involving a third party library and its plugins.
Not only such specific questions are not interesting, they teach you nothing.
I could have wrote this entire code myself in just a few minutes, but that would accomplish nothing, if you wanted to validate the password field, you would have had no idea where yo start.
Now, even if you're stuck you know what to do, and if you're not sure you can check the chat history in this room.
 
I definitely learned a lot
I sincerely appreciate your help. It adds a lot more value due to the fact that I have been on this thing for the past 2 months
@BenjaminGruenbaum check demcode.3eeweb.com
 
Uncaught TypeError: Cannot set property 'onsubmit' of null
 
fail
 
12:32 AM
When something doesn't work, open the developer tools console and check what error :)
This is because the form is not defined yet. jsfiddle wraps in an onliad
*onload
Put the code at the bottom of the body section of the page
It runs your code before it reads the body section, where the form is in, which causes getElementById to not find anything
(so the script should be right before `</body>
 
IT WORKSSSSSS!!!!!!!!!!!!!
 
Of course it does :) Mainly, because there is no magic there
All our code does is perfectly clear, no unexplained bugs like with plugins, just plain ol' javascript
 
Thank you so much @BenjaminGruenbaum I literally learned more in the past 2 hours than I did in the past 2 months
I am indebted to you :D
 
I'm glad I helped :) Good luck
I suggest you read some good JS books to get you started. If you don't like books codeacademy is a good video tutorial resources
While 'getting productive' might seem like the goal, the goal is really 'becoming a better programmer'
Programmers are problem solvers first :)
 
I thought upvoting a "few" of your things would return 5% of your help :D
 
12:38 AM
Don't upvote a few of my things, only stuff you read and like :)
 
(Also, if you vote more than 3 things, it'll probably revert anyway)
 
Oh Ill space it out. Don't worry!
 
Reputation in SO really doesn't matter that much to me, the important thing is learning :)
If you want to help me, find stuff you can answer and provide answers :) That's a lot more valuable, but only if you really know the answer.
 
i definitely will! :)
 

« first day  last day (14 days later) »