Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ajax'a modal aracılığı ile verileri aktaramıyorum.
Sory....
I am trying to transfer data to the data that I transferred to the link without a form, and I wanted to write a code to save it to the database via ajax post process via modal, but I was not successful.


What I have tried:

Link:
HTML
<a href="#" data-id="@Model._Advert.AdvertId" data-iadi="@Model._Advert.Title" data-uid="@KulID" data-cid="@Model._Advert.CompanyID" data-cvid="@cvID" data-seolink="@Model._Advert.SeoLink" class="btn btn-sm btn-primary pull-right BasvuruYap" style="color:#fff;" data-toggle="modal" data-target="#myModal">İlana Başvur</a>
Javascript:
JavaScript
<script>
$(".BasvuruYap").click(function () {
	var id = $(this).data("id");
	var iadi = $(this).data("iadi");
	var uid = $(this).data("uid");
	var cid = $(this).data("cid");
	var cvid = $(this).data("cvid");
	var seolink = $(this).data("seolink");
	$(".modal-body>p.mesaj").html(iadi + " isimli ilana başvuru yapılsın mı?");
	$(".BasvurOnay").data("id", id);
	$(".BasvurOnay").data("uid", uid);
	$(".BasvurOnay").data("cid", cid);
	$(".BasvurOnay").data("cvid", cvid);
	$(".BasvurOnay").data("seolink", seolink);
});

$(".BasvuruOnay").click(function () {
	var id = $(this).data("id");
	var uid = $(this).data("uid");
	var cid = $(this).data("cid");
	var cvid = $(this).data("cvid");
	var seolink = $(this).data("seolink");
	alert(id);
	alert(uid);
	alert(cid);
	alert(cvid);
	alert(seolink);
	$("#myModal").hide();
	$.ajax({
		type: "POST",
		url: @Url.Action("Basvur","Ilanlar"),
		data: { id: id, uid:uid, cid:cid, cvid:cvid },
		success: function (response) {
			if (response.Success) {
				window.location.replace("/tr/Ilanlar/Detay?seolink=" + seolink);
			} else {
				window.location.replace("/tr/Ilanlar/Detay?seolink=" + seolink);
			}
		}
	});
});
</script>
Modal:
HTML
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="modal-close" data-dismiss="modal" aria-label="Close"></button>
                    <h4 class="modal-title" id="myModalLabel">İlana Başvuru işlemi</h4>
                </div>
            <div class="modal-body">
                <p class="mesaj"></p>
                <p class="hata" style="color:red;"></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-rounded btn-default" data-dismiss="modal">İptal</button>
                <button type="button" class="btn btn-rounded btn-primary BasvurOnay">Evet</button>
            </div>
        </div>
    </div>
</div>
Posted
Updated 4-Feb-20 12:24pm
v2
Comments
ZurdoDev 4-Feb-20 16:11pm    
English. And be specific.
ZurdoDev 4-Feb-20 16:33pm    
You'll need to debug it to find out what is happening. We can't run it for you.
Richard MacCutchan 4-Feb-20 16:20pm    
Please translate, this is an English language forum. Alternatively find a Turkish language site.
MadMyche 4-Feb-20 18:40pm    
While you have provided the content of the View, you are missing the Model and the Controller/Action that is supposed to be doing this.
You may want to run this locally in debug mode and see what is happening in the Action the content is sent to.

1 solution

Sory....

I am trying to transfer data to the data that I transferred to the link without a form, and I wanted to write a code to save it to the database via ajax post process via modal, but I was not successful.
 
Share this answer
 
Comments
MadMyche 4-Feb-20 18:35pm    
This is not an answer, and should have been added to the original question via the "Improve Question" widget. I have transferred this information to your question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900