I have a problem with a script. i want to be able to create events and then to be shown with ajax

this is the javascript/ajax

$(".event_button").click(function() 
{

        $("#flash").show();
        $("#flash").fadeIn(400).html('Loading Update...');
        $.ajax(
        {
            type: "POST",
            url: "message_ajax.php",
            data: dataString,
            cache: false,
            success: function(html)
            {
                $("#flash").fadeOut('slow');
                $("#content").prepend(html);
                $("#event_title").val('').focus().css("height", "40px");    
                $('#preview_event').html('');
                $('#eventvalues').val('');
                $('#venue_name').val('');
                $('#event_img').val('');
                $('#event_description').val('');
            }
        });
        $("#preview_event").html();
});

this is the html

<form action="announce_event.php" id="eventform" method="post" enctype="multipart/form-data">
            <div id='preview_event'>
            </div>
            <div id='eventloadstatus'>
                <img src='<?php echo $base_url;?>wall_icons/ajaxloader.gif'/> Uploading please wait ....
            </div>
            <div class="wall">
                <div>
                    <span><input type="text" size="50" name="event_title" id="event_title"></span>
                </div><br />
                <div>
                <?php 
                include_once 'date_picker.php';
                ?>
                </div><br>
                <div>
                    <span><input type="text" name="venue_name" id="venue_name" size="50"></span>
                </div>
                <div>
                    <span><textarea name="event_description" id="event_description"  ></textarea></span>
                </div>
                <div id='eventloadbutton'>
                    <span><input type="file" name="event_img" id="event_img"></span>
                </div><br>
            </div>
                    <input type='hidden' id='eventvalues' />
        </form>
        <input type="submit" class="event_button" name="wall-post-event" id="event_button" value="Share">

When i press the submit button nothing happens. Any help?

And this is the message_ajax.php

if(isset($_POST['event_title']))
{
$eupdate=mysql_real_escape_string($_POST['event_title']);
$data=$Wall->Announce_Event($uid,$eupdate);
if($data)
{
include("html_messages.php");
}
}


public function Announce_Event($uid,$eupdate)
     {
    $event_id=mysql_real_escape_string($id);
$uid=mysql_real_escape_string($uid);
$title = $_POST['event_title'];
$date = $_POST['datetimepicker'];
$venue= $_POST['venue_name'];
$description = $_POST["update"];
$name = $_FILES['event_img']['name'];
$type = 'E';
$query = mysql_query("INSERT INTO user_uploads (id, uid_fk, title, date, venue_name, image_path, type, description) VALUES ('$event_id', '$uid', '$title', '$date', '$venue', '$name', '$type', $description)") or die(mysql_error());
     }

When i press the submit button nothing happens. Any help?

Line 10 in your code doesnt reference any existing variable. data: dataString

so i did this. still the same

$(".event_button").click(function() 

{
var event_title = $("#event_title").val();
var venue_name = $("#venue_name").val();
var event_img = $("#event_img").val();
var datetimepicker = $("#datetimepicker").val();
var event_description = $("#event_description").val();
        $("#flash").show();
        $("#flash").fadeIn(400).html('Loading Update...');
        $.ajax(
        {
            type: "POST",
            url: "message_ajax.php",
            data: {event_title: event_title, venue_name: venue_name, event_img: event_img, datetimepicker: datetimepicker, event_description: event_description},
            cache: false,
            success: function(html)
            {
                $("#flash").fadeOut('slow');
                $("#content").prepend(html);
                $("#event_title").val('').focus().css("height", "40px");    
                $('#preview_event').html('');
                $('#eventvalues').val('');
                $('#venue_name').val('');
                $('#event_img').val('');
                $('#event_description').val('');
            }
        });
        $("#preview_event").html();
});

Now i am getting an Sql message

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1

$(".event_button").click(function() 

{

    $("#eventform").submit(function(e)
{

    var formObj = $(this);
    var formURL = formObj.attr("action");
    var formData = new FormData(this);


        $("#flash").show();
        $("#flash").fadeIn(400).html('Loading Update...');
        $.ajax(
        {
            type: "POST",
            url: "message_ajax.php",
            data: formData,
            mimeType:"multipart/form-data",
            cache: false,
            success: function(html)
            {
                $("#flash").fadeOut('slow');
                $("#content").prepend(html);
                $("#event_title").val('').focus().css("height", "40px");    
                $('#preview_event').html('');
                $('#eventvalues').val('');
                $('#venue_name').val('');
                $('#event_img').val('');
                $('#event_description').val('');
            }
        });
        $("#preview_event").html();

        });
$("#eventform").submit(); //Submit the form
});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.