I am building a competition sign-up page for our annual math competition in my school. When you click an item in the dropdown list and select an item, it requires some AJAX behavior.
When I select something in the dropdown (I'm currently showing a warning box):
What it needs to do, is making an asynchronous call on the server to get a list of current competitors.
I know that I need a jquery AJAX call because I think my ON Student Change () function will look like this:
$ Ajax ({type: 'POST', url: 'get_registered_events.php', datatype: 'Jason', data: {Studentid: $ ('# student'). Val ()}, success: function (data) {// For some time we obtain data}, error: function (XMLHttpRequest, textStatus, errorThrown) {// display error}}); return false; });
So I went ahead and got get_registered_events.php
, for which I want to return the student registration events.
My problem is, I have not had experience with PHP and I find it difficult to know how I will return the data, the database gave me this Ajax call in the AJAX column. I have another problem: Our school is using a very old version of PHP, so I have to use this library.
It is that I have a problem with the PHP file:
So my question is, how can I convert $ contests (its rows) into JSON (contest.id, contest.title), and return to that AJAX call
If someone can point me in the right direction, then I appreciate it.
No comments:
Post a Comment