Can anyone tell what would be the correct syntax for data

var ev = $("#update").val();
    var up=$("#upload").val();


            data: ______,

Recommended Answers

All 5 Replies

Generally its in json format. How you specify it depends on what the server side method is expecting.

For example:

 data: {key1: 'value1', key2: 'value2'}

You mean that the key1 is the field on my MySql table and the value is my id on the html form right?

Not necessarily, but it could be. Your .ajax method is sending data to a web service runing server side correct? Your server side script should be expecting certain parameters. These would be your keys. Yes, the values are coming from your form.

There are several examples on the jQuery site:

this is my form

<textarea name="update_event" id="update_event"  ></textarea>
            <form id="imageform_event" method="post" enctype="multipart/form-data" action='announce_event.php'> 
            <div id='preview_event'>
            <div id='imageloadstatus'>
                <img src='<?php echo $base_url;?>wall_icons/ajaxloader.gif'/> Uploading please wait ....
            <div id='imageloadbutton' class="wall">
                <span id='addphoto'><b>Add Photo:</b></span> <input type="file" name="photoimg_event" id="photoimg_event" />
            <input type="text" id='title_event' />
           <input align="middle" type="submit" class="event_button AudioSearchButton" align="middle" name="event_button" id="event_button" value="Share">

and this the ajax. The problem is that the button doesn't do anynothing

    var updateval = $("#update_event").val();
    var uploadvalues=$("#photoimg_event").val();
    var title=$("#title_event").val();

    var dataString = 'description='+ updateval+'&image_path='+uploadvalues+'&title='+ title+'&image_path='+uploadvalues;
        alert("Please Enter Some Text");
        $("#flash").fadeIn(400).html('Loading Update...');
            type: "POST",
            url: "message_ajax.php",
            data: dataString,
            cache: false,
            success: function(html)
                $("#update_event").val('').focus().css("height", "40px");   
                var c=$('#update_count').html();
    return false;
Be a part of the DaniWeb community

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