javascript - jquery json php html does not show results -
i'm trying use jquery json , returning results replacing div class alert. know js uses alert im gonna change later.
im kinda stuck here, post seconds file (offerte2.php) doesnt show results.
i'm not sure if java or php fault. has ideas?
script.js:
$(document).ready(function() { var form = $('#form'); var submit = $('#submit1'); var page1 = $('.page1'); form.on('submit', function(e) { e.preventdefault(); $.ajax({ url: '******/shop/templates/euphoria-art/offerte2.php', // form action url type: 'post', // form submit method get/post datatype: 'json', // request type html/json/xml data: form.serialize(), // serialize form data beforesend: function() { page1.fadeout(); }, success: function(result) { if(result.error){ page1.html(result.html).fadein(); console.log(e) }else{ page1.html(result.html).fadein(); form.trigger('reset'); } } }); }); });
to capture values
<?php header('content-type: application/json'); if( isset( $_server['http_x_requested_with'] ) ){ $class1 = filter_var($_post['class1'], filter_sanitize_string); $class2 = filter_var($_post['class2'], filter_sanitize_string); $class3 = filter_var($_post['class3'], filter_sanitize_string); $class4 = filter_var($_post['class4'], filter_sanitize_string); $class5 = filter_var($_post['class5'], filter_sanitize_string); $result = array("error" => false, "html" => null); $totaal1 = $class1 + $class2 + $class3 + $class4 + $class5 $result["error"] = false; $result["html"] = "<h3>het totaal .$totaal1.</h3>"; echo json_encode($result); exit; } ?>
all seems fine unless missed semicolon after $class5
$totaal1 = $class1 + $class2 + $class3 + $class4 + $class5; if( isset( $_server['http_x_requested_with'] ) ){ $class1 = filter_var($_post['class1'], filter_sanitize_string); $class2 = filter_var($_post['class2'], filter_sanitize_string); $class3 = filter_var($_post['class3'], filter_sanitize_string); $class4 = filter_var($_post['class4'], filter_sanitize_string); $class5 = filter_var($_post['class5'], filter_sanitize_string); $result = array("error" => false, "html" => null); $totaal1 = $class1 + $class2 + $class3 + $class4 + $class5; $result["error"] = false; $result["html"] = "<h3>het totaal .$totaal1.</h3>"; } else { $result["error"] = true; $result["html"] = "<h3>error</h3>"; } echo json_encode($result); exit;
Comments
Post a Comment