felito Posted October 20, 2011 Share Posted October 20, 2011 hi i have this code: <script type="text/javascript"> $(document).ready(function() { function doAjax(url) { $("#customForm").submit(function() { var formdata = $("#customForm").serializeArray(); $.ajax({ url: url, type: "post", dataType: "json", data: formdata, success: function(data, data1) { switch (data.livre) { case 'tituloLivre': $("#msgbox2").fadeTo(200, 0.1, function() { $(this).html('Titulo Livre').fadeTo(900, 1); }); break; default: $("#msgbox2").fadeTo(200, 0.1, function() { $(this).html('Active a sua conta e pode efectuar o login!').fadeTo(900, 1, function() { $('#conteudo').load('dojo/test_Slider.php'); }); }); break; } } }); return false; }); } doAjax('sent.php'); doAjax('dojo/test_Slider.php'); }); </script> and test_Slider.php <?php include ('includesMy.php'); $form = $_POST['item']; $oferta = $form['oferta']; var_dump($oferta); echo json_encode ($oferta); ?> i should load the php file with ajax influence, but when i made load (test_Slider.php) obviously i get null because is independent of ajax call. My question is, how can i load a whole php file that is changed by ajax call ? (json return is not the solution because i have much more content, like graphics elements in test_Slider.php) Quote Link to comment https://forums.phpfreaks.com/topic/249492-problem-with-load-null-value/ Share on other sites More sharing options...
requinix Posted October 20, 2011 Share Posted October 20, 2011 You can just echo out an HTML fragment and it'll be inserted into whatever element you're .load()ing from. Quote Link to comment https://forums.phpfreaks.com/topic/249492-problem-with-load-null-value/#findComment-1280972 Share on other sites More sharing options...
felito Posted October 20, 2011 Author Share Posted October 20, 2011 ok, but i will get null value to $oferta. The main problem is that output of php file depends of ajax call. if i submit "programmer"or "designer" word, when i make the load();, i must see the previous input. At the moment, when i make load(); i will get always null, because is independently of input. Quote Link to comment https://forums.phpfreaks.com/topic/249492-problem-with-load-null-value/#findComment-1280975 Share on other sites More sharing options...
requinix Posted October 20, 2011 Share Posted October 20, 2011 Only kinda sure I understand what you want. Modify the URL to include whatever data the test_Slider needs. Like "page.php?key=" + encodeURIComponent(value) Quote Link to comment https://forums.phpfreaks.com/topic/249492-problem-with-load-null-value/#findComment-1280978 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.