ajax - Page not getting redirected php -
i have passed values page using ajax request method post. there 1 condition f 1 directly accessing url, should redirected other page. problem not getting redirected (in else condition in img.php) . can 1 tell me mistake committing?
thanks in advance.
code:-
imageupload.php:
document.getelementbyid("submit").addeventlistener("click", function(event){ event.preventdefault(); saveimgfunc(); }); function saveimgfunc(){ var form = new formdata(document.getelementbyid('saveimg')); var file = document.getelementbyid('imgvid').files[0]; if (file) { form.append('imgvid', file); } $.ajax({ type : 'post', url : 'core/img.php', data : form, cache : false, contenttype : false, processdata : false }).success(function(data){ document.getelementbyid('msg').innerhtml = data; }); }
img.php:
<?php require '../core.php'; $qry = new processquery('localhost', 'root', '', 'mkart'); $uid = 6; if($_server["request_method"] == "post"){ //some code here } else{ header("location : ../core.php"); }
see post https://stackoverflow.com/a/21229246/682754
there's chance may have whitespace before use header function? perhaps in form of hidden error/warning.
try following @ top of php code in img.php
error_reporting(e_all); ini_set('display_errors', true);
would advise removing once you've found issue
Comments
Post a Comment