Ajax issue on OOP page.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Aristona
Forum Commoner
Posts: 33
Joined: Thu Dec 02, 2010 8:14 am

Ajax issue on OOP page.

Post by Aristona »

Hey,

I made a translation project for a popular game called League of Legends.
I am trying to insert form data into Mysql using JSON Ajax.

Code: Select all

<script type="text/javascript">
$(function(){
    $("#JqAjaxForm").submit(function(e){
       e.preventDefault();

        dataString = $("#JqAjaxForm").serialize();
        $.ajax({
        type: "POST",
        url: "?page=translate&skillID=<%SKILL_ID%>",
        data: dataString,
        dataType: "json",
        });      
	$("#ajaxReply").fadeOut(15000).html("<fieldset><div class='Message'>Successfully translated."); 
    });
});
</script>
Imagine this having a success: function() like: (CURRENTLY THE ABOVE SCRIPT HAS NO SUCCESS FUNCTION, IT SHOWS MESSAGE WHENEVER THE BUTTON IS CLICKED.)

Code: Select all

success: function() { $("#ajaxReply").fadeOut(15000).html("<fieldset><div class='Message'>Successfully translated.");  }
My problem is;
It works perfectly when I use a basic .php page with echo "Saved!"; content, however, when I try to use it on a OOP page, it never recognise success: function().

OOP page posts the value into database though. (When I check Mysql, the translation is there.)

What could be wrong?

People who wants to test it
1. Enter here http://www.anilunal.com/lol/#!?page=tra ... killID=250
2. Input something into two textboxes, click on button.
3. You will get this "Çeviri veritabanına başarıyla kaydedildi!" message in a fieldset, which keeps fading off. (It is the translation of "Translation successfully added to database")
4. I need to get this working in success: function() area ONLY and not "everytime" the button is clicked.
5. The following script (the OOP one) NEVER returns a success message, while a basic php page with echo "booo"; content only does.

Code: Select all

<?php
	
	if (!defined('ARISTONA') || ARISTONA != 1)
		die();
		
	class Page
	{
		function __construct($site)
		{
		}

		function Run()
		{
		        echo "Boo";
                }
		
		function __destruct()
		{
		}
	}
	
?>
1. Run() function always runs. I mean, it is currently saving posted data into database, so it works. (Index.php force page class to run the Run() function, so it runs basicly.)
2. If I erase the if (!defined('ARISTONA') || ARISTONA != 1) part, the result is still same. No difference.

Any ideas?
Post Reply