0

I wrote a function in jquery and it works perfectly on localhost with the same setting

$('#resumey_graduation_add').live("click",function(){

    var dataString=$('#job_form').serialize();

    $.ajax({
        type: 'GET',
        url: 'app.php?name=job&op=resumey_graduation_add',
        data: dataString,
        cache: false,
        beforeSend: function() {
            $("#resumey_graduation_showall").html("<img src='images/loading.gif' />");
        },
        success: function(data2) {
            $("#resumey_graduation_showall").html(data2);
        }
    });
    return false;
});

but when moving it on my host , its not working and failed to load the data .

loading shows but not the result !

jquery versions are all tested and none of them worked

is there anything wrong , for expample not having JSON enabled or these things that are related to serialize() in jquery ?!

Mac Taylor
  • 5,020
  • 14
  • 50
  • 73
  • Are you sure that "app.php" is installed on your server? – Pointy Mar 02 '11 at 16:40
  • Can you provide a link to the hosted website? – Chi Chan Mar 02 '11 at 16:41
  • Have you checked that the ajax request is actually going out? What's the server-side script seeing coming in? If it's expecting a regular form submission and you send in that serialized data instead, it's not going to magically unserialize it for you. – Marc B Mar 02 '11 at 16:42
  • guys as i said , its working fine at localhost !!! when i remove serialize() it will work at web host . something is wrong with serialize and this web host ! – Mac Taylor Mar 02 '11 at 16:57
  • If it's not working, then you need to be looking at what the outgoing HTTP request looks like that's different from when it happens on your local machine. Try the [Tamper Data](https://addons.mozilla.org/en-us/firefox/addon/tamper-data/) plugin for Firefox - it's a great help. – Pointy Mar 02 '11 at 17:00
  • Yep, you definitely need to use Fiddler or Firebug (or something else) to inspect the request and response. – Andy Gaskell Mar 02 '11 at 17:15
  • thanks guys . i changed GET into POST and it solves my problem . problem was in sending huge amount of serialized data and server not accepting it – Mac Taylor Mar 02 '11 at 17:36

1 Answers1

0
Since you are doing 
type= get ,  data= $('#job_form').serialize(), url=Someurl.php?a=b&c=d

your url must be getting converted to Someurl.php?a=b&c=d&props_from_form(name value pairs)

Do this way

$.ajax({
        type: 'POST',
  other things ....

sending form through GET may result in very big urls and that may get ignored by server.

Praveen Prasad
  • 31,561
  • 18
  • 73
  • 106
  • i know how to change it into normal ajax function ! i need to do it in serialize way , cause i have to send 200 input values in this form . – Mac Taylor Mar 02 '11 at 16:58
  • since you are sending 200 name/values pairs and using GET method, ur url must be becoming to large and ur server must be ignoring after 255 character. – Praveen Prasad Mar 02 '11 at 17:12
  • 255? Quit making stuff up! http://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request – ken Mar 02 '11 at 17:19
  • so how to change its size ?! and is there any choice for doing this thing ? – Mac Taylor Mar 02 '11 at 17:26
  • YEY ,,, at last i found the solution by ur nice comment . just changing GET into POST , it solves the problem ... it refers to huge amount of data – Mac Taylor Mar 02 '11 at 17:30
  • @ken: u r right, i was just thinking something else. its around 2000 characters, also depend on server and browser. – Praveen Prasad Mar 02 '11 at 17:31
  • @Mac: u have to find it ur self how to increase the allowed url length. but change ur request type:post, as i have mentioned in answer, that way u can send large size data, also it is more secure way. – Praveen Prasad Mar 02 '11 at 17:34