Hi,  I personally prefer to use $.getJSON for this sort of thing,
seems to do a better job with the JSON parsing and all that:

$.getJSON(_HOMEDIR+"send?"+str, ...

However, I'm wondering if "send" is actually the name of the file you
want to invoke?  Perhaps you left the .php off in your url string?

_HOMEDIR+"send.php?"+str

Also, I think you have a parameter for the error function

error: function(result) {
...

Have you looked at the error console under Firebug?  That might give
you some clues...

On Jul 28, 7:38 am, shaf <shaolinfin...@gmail.com> wrote:
> Hi Guys
>
> I am trying to make an ajax POST request but its not working. Code
> below:
>
> var _HOMEDIR = "http://localhost/personal/index.php/home/";;
>
> $(document).ready(function() {
>         $("form").submit(function() {
>                 var str = $("form").serialize();
>                 $.ajax({
>                         type: "POST",
>                         async: false,
>                         url: _HOMEDIR+"send?"+str,
>                         dataType: "json",
>                         beforeSend: function() {
>                                 $("span:last").text("Sending..").show();
>                         },
>                         error: function() {
>                                 $("span:last").text("Failed. Please try 
> again").show();
>                         },
>                         success: function(data) {
>                                 if(data.type == "failed") {
>                                         $("span:last").text("Please enter 
> valid data for each field").show
> ();
>                                 } else {
>                                         $("span:last").text("Thank you for 
> your message").show();
>                                 }
>                         }
>                 });
>
>                 return false;
>         });
>
>
>
> });- Hide quoted text -
>
> - Show quoted text -

Reply via email to