0

I hope someone could help me.

When i load an external php that generates a set of fields, i have no problems, but then i send the generated form, i can not access the vars.

There is the code i user:

For load the external file:

      $.ajax({

    type: "POST",
    url: "product-insert.php",
    contentType: "application/x-www-form-urlencoded",
    global: true,
    processData:true,
    dataType: 'html',
    data: {num_filas: $("#num_filas").val()},

    success: function(html){
             $("#destino").html(html);
             alert(html);
             str = $("ofertas").serialize();
    },

    error: function(){
    },

    complete: function(){
    }
});


  <form action="ofertas.php" method="post" enctype="multipart/form-data" name="form-ofertas" id="ofertas" >

  <div id="destino"></div>

The file loaded have this code:

echo '<input name="campo" type="hidden" value="valor" />';

and the php file that receive the form have this code:

die("campo: ".$_REQUEST['campo']);

I really will appreciate a lot the help.

Thnx in advance.

Yannick

SauronZ
  • 1
  • 2

2 Answers2

0

Based upon your comment, you're checking for $_POST['campo'] despite the fact that your <form> tag's method is a GET request. You should instead check the value of $_GET['campo'] (or $_REQUEST['campo']).

Matt Huggins
  • 81,398
  • 36
  • 149
  • 218
  • i've tried, but still not working :( I think problem is that the values of the form dinamically loaded are not sent when click the submit button. Maybe if i send the form using jquery will work? Thnx in advance. – SauronZ Jun 29 '10 at 22:39
  • Do you have a `` tag? You didn't include it in your question if you do. – Matt Huggins Jun 29 '10 at 23:27
0

I'm guessing partially off comments here, your form looks like this:

<form action="ofertas.php" method="get" enctype="multipart/form-data" 
 name="form-ofertas" id="ofertas"> 
  <div id="destino"></div> 
</form> 

Your method is GET, which won't give you what you're after if you're looking for the values in the POST collection, which $_POST does. Just change the method on your form to method="post" to get this working correctly, otherwise use $_GET on the PHP side, if a GET is what you're actually after.

For a good discussion of GET vs POST, take a look here:
When do you use POST and when do you use GET?

Community
  • 1
  • 1
Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
  • @Nick Craver I have updated the code, but still not working. The mistake of POST and GET was due to so many changes :) – SauronZ Jun 29 '10 at 22:37
  • @SauronZ - now you have 2 `success` functions defined...need that not to be the case, remove the first and put the `alert()` in the second, what's the result then? – Nick Craver Jun 29 '10 at 22:40
  • @Nick Craver - Removed in code and in example, but still the same.I really don't know what can be happening :( – SauronZ Jun 29 '10 at 22:48
  • @SauronZ - I don't know what's run from the info provided...any chance there's a page I can hit? – Nick Craver Jun 29 '10 at 22:52
  • @Nick Craver- http://ulzama.es/admin/ofertas.phpn=1 - User/pass: Nick - Press the second Radio button and continue. Then you have the form. Simply enter 2 in the last field and click Añadir productos, it will load the external field. Really thnx for your patience – SauronZ Jun 29 '10 at 22:56
  • @SauronZ - I had to run for dinner, can't login now though, let me know if you can re-enable it. – Nick Craver Jun 30 '10 at 00:27