Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

SIMPLE AJAX CALL and open the page in new tab-loosing post value

I am trying to open second page this POST values (id_od_client, reports array, which includes only type of report and id of report). I want to generete report via phpword, but I have problem, that values are not posted. I think, it is due to posts and open page after success lost posted data. I am trying

var url="complete_report.php?Id="+id_client;
$.ajax({
    url: url,
    type: "POST",
    data: {
        "id_client": id_client,
        "report_array": report_array,
                            },
        success: function(data){
////not work as expected window.location = url; 
////not work as expected window.open('complete_report.php?Id='+id_client, '_blank');
////not work as expected window.location.href=url;
                    }
                        });

if I try in complete_report.php condition if(isset($_POST['id_client])) it not work. Data are OK, but how to open in in new tab with posted data.If I tried method get and open file beforeSend it worked as expected. Must be form action added in html form or somethink like that? I think my issue is loosing POST value because of opening it later. I could be solved by sessions/cookies but it must be solved without that. Also problem could be that complete_report does not anwering anything, just only create doc file. I am not able to found the solution. Kind regards

question from:https://stackoverflow.com/questions/65843398/simple-ajax-call-and-open-the-page-in-new-tab-loosing-post-value

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have solved it via adding action="complete_report.php" in html form and adding hidden input field in form(id_client and report_array) and jquery submit function. It works, but I dont know how to made it via simple ajax method (or post...)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...