Category Archives: jquery

Apache Cordova $.ajax not working( using Web.APİ)

im making an mobile app using API but ajax not working. i take breakpoint on ajax but not see. and my other project is work and they are exactly the same .and the jquery codes in this project are working

This inside onDeviceReady


            method: "post",
            url: "http://localhost:53407/api/kullanici/kullanicikayit",
            data: yeniKullanici,
            success: function () {
                alert("Kayıt Başarılı");
                window.location.href = "index.html";
            error: function () {
                alert("Lütfen bilgilerinizi kontrol ederek tekrar deneyiniz.");

and this is my APİ Controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Cors;
using BitirmeProjesi.Server.Models;

namespace BitirmeProjesi.Server
    public class KullaniciController : ApiController
        public void KullaniciKayit(Kullanicilar kullanici)
            Kullanicilar yeniKullanici = new Kullanicilar();
            yeniKullanici.KullaniciAdi = kullanici.KullaniciAdi;
            yeniKullanici.Mail = kullanici.Mail;
            yeniKullanici.RoleId = 1;
            yeniKullanici.Sifre = kullanici.Sifre;
            yeniKullanici.Soyad = kullanici.Soyad;
            yeniKullanici.Ad = kullanici.Ad;



EU Cookie Law: Block Cookies set by a specific JS File?

i try to block / disable only cookies set by an specific JS File. In my Case the file is.

I don't want to block the hole file, i only want to block cookies that are set by these file.

I test Cookie blocking by unset the header in .httacces, but it didn't work.

<IfModule mod_headers.c>
RequestHeader unset Cookie
Header unset Cookie
Header unset Set-Cookie

I want the file to load normally, but without permission to create cookies.

If Cookies are not allowed in the Browser Software, Adsense is showing ads normaly, but don't load cookies. So why to ask user permission and after that load the adsense script? Wouldn't it be better to block all Cookies generaly or only for that special file. So you don't need a Cookie permission.

Cookie Consent Plugins like these block the hole Script and reenable it after Cookie Permission.

But that is a big Problem, because you lose Money. It makes no sence.

Example (Not a good solution, Because blocked on Pageview and only load after user permission)

<script **type="text/plain"** class="cc-onconsent-inline-advertising">
google_ad_client = "ca-pub-0000000000000000";
google_ad_slot = "0000000000";
google_ad_width = 728;
google_ad_height = 90;
<script type="text/plain" class="cc-onconsent-inline-advertising"

Does anyone have an idea how to block cookies from an JS File with Jquery, Javascript, per PHP or htacess?

Htaccess change kills form submission and gets error

I edited my htaccess so I can remove the php extension from my URL. The code below works. However, the moment I added the "remove php ext" lines below, my jquery contact form fails to submit (I keep getting an error). I am using the following.

RewriteEngine on

# remove php ext
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [NC,L]

# http to https
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

# Add www to any URLs that do not have them:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

You can preview the page here (before the code was added). Click the GET THE DEMO button to view the form (opens in a modal window). The code for the form is at the bottom of the page.

js not submitting form by setting dynamic action

working on wordpress, having page template, there is ajax call which check the voucher code and set the action dynamically, and submit form to redeem voucher,

                    type: 'POST', 
                    url: ajaxurl, 
                    data: action_data, 
                    dataType: 'json',
                    success: function (response) { 

                            var redirectUrl = "<?php echo get_bloginfo('url'); ?>/"+response.redirect_link+"/";


                            //return true;

Also i have rule in my htaccess that all urls should append "/" in the end otherwise redirect it to referrer URL,

RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteCond %{REQUEST_URI} !wp-json/contact-form-7/v1/contact-forms/1404/feedback
RewriteCond %{REQUEST_URI} !wp-json/contact-form-7/v1/contact-forms/1740/feedback
RewriteCond %{REQUEST_URI} !wp-json/contact-form-7/v1/contact-forms
RewriteRule ^(.*)$$1/ [L,R=301]

Problem if i hardcode action in tag it works fine, but through setting jquery doesn't submit. also i have check the response in ajax also alerted redirect link have "/" also in the end, and in network tab, however it redirect to dynamic url through jquery, but show 302 error in network tab, sorry for my bad english , open to answer any question, any idea guys?

Datepicker jQuery on Apache Webserver [duplicate]

This question already has an answer here:

I want to change jQuery Datepicker to German Calendar, but it did not work.

-I tried that :

  $( function() {
    $( "#datepicker" ).datepicker( $.datepicker.regional[ "de" ] );
    $( "#locale" ).on( "change", function() {
      $( "#datepicker" ).datepicker( "option",
        $.datepicker.regional[ $( this ).val() ] );
  } );

Thank you!

i18next multilanguage site with URL change

I am trying to add multiple language support to a web-site, that doesn't have .php files and I am doing it with i18next. But URLs now need to be like www.mysite/en/about/. I decided to make something like that

 window.history.pushState("", "", '/en' + window.location.pathname);

And then on changing the language:

 $('.lang').on("change", function() {
    window.history.pushState("", "", '/' + $(this).val() + window.location.pathname.substring(3));
    i18next.changeLanguage($(this).val(), function() {

The problem is when someone shares a link like www.mysite/fr/about/ it gets an error. I can redirect it to www.mysite/about/ via .htaccess, but how can I then get the language "/fr" parameter?

If you know any other ways around without using .htaccess, I'll be glad to hear them out.

Thank you for your help.


The error is 404. The routing is simply folders with .html files.

redirect from www. to root domain ( without www.)

How do you force the root domain uses? I want to know how to do this in

html, php, Javascript, .htaccess,jQuery,  ajax.

I know about the meta refresh

as shown here:

<meta http-equiv="refresh" content="0; url=" />

and here I know this too:

<body onload="window.location.href = 'your URL';"></body> 

as well as: Php

<?php header('Location:'); ?> 

but none of those work for what I want. Multiple methods would be nice!

Cross domain AJAX 403 Error

I am getting a 403 Forbidden status code when making an AJAX GET call from another domain. It works if I put the files on the same domain but I would like to enable cross domains. My code is:

    url: "",
    type: "GET",
    headers: {
        'authkey': 'password'
        dataType: "json",
        contentType: 'application/json',
        async: true,
        xhrFields: {
            withCredentials: true
        crossDomain: true,
        success: function (data, textStatus, xhr) {
   error: function (xhr, textStatus, errorThrown) {


I have this in htaccess:

Header set Access-Control-Allow-Origin ""
Header set Access-Control-Allow-Credentials true
Header set Access-Control-Allow-Headers "*"
Header set Access-Control-Allow-Method "*"

The console says this:


Request URL:
Request Method:OPTIONS
Status Code:403 Forbidden
Remote Address:
Referrer Policy:no-referrer-when-downgrade


Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:keep-alive, Keep-Alive
Content-Type:application/json; charset=utf-8
Date:Sat, 29 Jul 2017 09:13:10 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.4.27 (cPanel) OpenSSL/1.0.2k mod_bwlimited/1.4
Set-Cookie:currency=EUR; expires=Mon, 28-Aug-2017 09:13:10 GMT; path=/;
Set-Cookie:language=sl-SI; expires=Mon, 28-Aug-2017 09:13:10 GMT; path=/;
Set-Cookie:PHPSESSID=03opu95ddo4fon0udk7ho4rvl5; path=/; HttpOnly
Set-Cookie:default=eba7a5c318db689b3b11473819; path=/; httponly


Accept-Encoding:gzip, deflate, br
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36

Anybody got an idea what am I missing here? Maybe a thing in htaccess?


Php dynamic subpage and nginx address rewriting

I created a website based on ajax tech. and now I want to achieve similar effects using php (nginx). The problem is I don't want to create (even dynamically) .php documents for every user or offer or anything. I have templates for every pages like userTemplate.php and it works fine with $_GET method, which fill it with proper data BUT the address is not acceptable, hoe can I convert that to I tried with rewriting it in config files, but then it redirects me to the path /users/1 which is ofc wrong... Is it possible? Please I've already spent hours looking for any answer.