PHP file not call using $.post (JQuery version I should used?) - php

Test.js:
$(document).ready(function() {
$.post('MYLogic.php', null, function(response) {
});
});
Can any one tell me which jQuery or version of JQuery should I include on my JSP page to call PHP class using $.post
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link type="text/css" href="css/common.css" rel="stylesheet" />
<link type="text/css" href="css/screen.css" rel="stylesheet" />
<link type="text/css" href="css/menu.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="scripts/test.js"></script>
<title>Mobilezone Afghanistan</title>
</head>

Try this
Remove null
$(document).ready(function() {
$.post('MYLogic.php', function(response) {
});
});

Related

Why Laravel component does not render correctly? Depends on the route?

When I hit http://127.0.0.1:8000/welcome everything renders fine.
But with http://127.0.0.1:8000/hh/welcome the page looks like it has no CSS references or anything at all.
Any idea why it is like this and how to solve it?
Thanks a lot!
routes > web.php
Route::get('/hh/welcome', [BikeController::class, 'show']);
Route::get('welcome', [BikeController::class, 'show']);
app > Http > Controllers > BikeController.php
public function show(Bike $bike)
{
return view('bikes.show', [
'bike' => $bike
]);
}
resources > views > bikes > show.blade.php
<x-layout>
<h1>Hello World!</h1>
</x-layout>
resources > views > components > layout.blade.php
<!DOCTYPE html>
<html lang="de" dir="ltr">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>BM | Dashboard & Web App Template</title>
<link rel="apple-touch-icon" sizes="180x180" href="assets/img/favicons/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="assets/img/favicons/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="assets/img/favicons/favicon-16x16.png" />
<link rel="shortcut icon" type="image/x-icon" href="assets/img/favicons/favicon.ico" />
<link rel="manifest" href="assets/img/favicons/manifest.json" />
<meta name="msapplication-TileImage" content="assets/img/favicons/mstile-150x150.png" />
<meta name="theme-color" content="#ffffff" />
<script src="assets/js/config.js"></script>
<script src="vendors/overlayscrollbars/OverlayScrollbars.min.js"></script>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,600,700%7cPoppins:300,400,500,600,700,800,900&display=swap" rel="stylesheet" />
<link href="vendors/overlayscrollbars/OverlayScrollbars.min.css" rel="stylesheet" />
<link href="assets/css/theme-rtl.min.css" rel="stylesheet" id="style-rtl" />
<link href="assets/css/theme.min.css" rel="stylesheet" id="style-default" />
<link href="assets/css/user-rtl.min.css" rel="stylesheet" id="user-style-rtl" />
<link href="assets/css/user.min.css" rel="stylesheet" id="user-style-default" />
<script>
var isRTL = JSON.parse(localStorage.getItem("isRTL"));
if (isRTL) {
var linkDefault = document.getElementById("style-default");
var userLinkDefault = document.getElementById("user-style-default");
linkDefault.setAttribute("disabled", true);
userLinkDefault.setAttribute("disabled", true);
document.querySelector("html").setAttribute("dir", "rtl");
} else {
var linkRTL = document.getElementById("style-rtl");
var userLinkRTL = document.getElementById("user-style-rtl");
linkRTL.setAttribute("disabled", true);
userLinkRTL.setAttribute("disabled", true);
}
</script>
</head>
<body>
<main class="main" id="top">
<div class="container" data-layout="container">
<script>
var isFluid = JSON.parse(localStorage.getItem("isFluid"));
if (isFluid) {
var container = document.querySelector("[data-layout]");
container.classList.remove("container");
container.classList.add("container-fluid");
}
</script>
#include('_nav-vertical')
<div class="content">
#include('_nav-top')
{{ $slot }}
#include('_footer')
</div>
{{-- #include('_modal') --}}
</div>
</main>
<script src="vendors/popper/popper.min.js"></script>
<script src="vendors/bootstrap/bootstrap.min.js"></script>
<script src="vendors/anchorjs/anchor.min.js"></script>
<script src="vendors/is/is.min.js"></script>
<script src="vendors/echarts/echarts.min.js"></script>
<script src="vendors/fontawesome/all.min.js"></script>
<script src="vendors/lodash/lodash.min.js"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=window.scroll"></script>
<script src="vendors/list.js/list.min.js"></script>
<script src="assets/js/theme.js"></script>
</body>
</html>
Because you are currently loading your CSS relative to your URL
Try the following:
<link href="{{asset('assets/css/example.css')}}" rel="stylesheet"/>
or take a look at: https://laravel.com/docs/9.x/helpers#method-asset
You are loading assets in the wrong way actually in your layout.blade.php made these modifications. Then it will work fine. Apply this to your all assets like Images, CSS, and JS files. Apply asset function with every asset like this in curly braces.
<link href="{{ asset('assets/css/theme-rtl.min.css') }}" rel="stylesheet" id="style-rtl" />
Apply this on all CSS also on JS like this
<script src="{{ asset('vendors/popper/popper.min.js') }}"></script>
Also make sure all files are aviable on disk.

how to avoid header and footer html code when getting data from ajax in zend framework?

I am having some problem with the ajax . I want to get image name only using ajax but I am getting header and footer content instead of image name..
here is my code.
controller file
public function deleteimageAction() {
$id = (int) $this->params()->fromRoute('id', 0);
$image = $_POST['image'];
return $image;
}
and my ajax-
$('.delete').click(function(e){
var imageName=$(this).attr('data');
var id=$(this).attr('id');
$.ajax({
url:'/test/zend/public/business/deleteimage/'+id,
type: 'POST',
data:{id:id,image:imageName,},
success: function (data) {
alert('Success : please check console')
console.log(data);
},
error:function(data) {
alert('Error : please check console')
console.log(data);
}
});
});
and getting the following result in the console -
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ZF2 Skeleton Application</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Le styles -->
<link href="/test/zend/public/css/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/test/zend/public/css/style.css" media="screen" rel="stylesheet" type="text/css">
<link href="/test/zend/public/css/bootstrap-responsive.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/test/zend/public/images/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
<!-- Scripts -->
<script type="text/javascript" src="/test/zend/public/js/jquery.min.js"></script>
<script type="text/javascript" src="/test/zend/public/js/bootstrap.min.js"></script>
<!--[if lt IE 9]><script type="text/javascript" src="/test/zend/public/js/html5.js"></script><![endif]-->
</head>
<body>
</body>
</html>
public function deleteimageAction() {
$id = (int) $this->params()->fromRoute('id', 0);
$image = $_POST['image'];
echo $image;
exit();
}

Why Ajax is not working in my page

Please help, ajax is not working..
I tried the tutorial from here,
Ajax box PHP
it works well, but when the code is installed in a different page, I just don't want to work.
here is codes
<!DOCTYPE html>
<html lang="en">
<head>
<script src="typeahead.min.js"></script>
<script>
$(document).ready(function(){
$('input.typeahead').typeahead({
name: 'typeahead',
remote:'search.php?key=%QUERY',
limit : 10
});
});
</script>
<link rel="stylesheet" type="text/css" href="asset/css/bootstrap.min.css">
<script src="typeahead.min.js"></script>
<link rel="stylesheet" type="text/css" href="asset/css/plugins/font- awesome.min.css"/>
<link rel="stylesheet" type="text/css" href="asset/css/plugins/simple-line-icons.css"/>
<link rel="stylesheet" type="text/css" href="asset/css/plugins/animate.min.css"/>
<link rel="stylesheet" type="text/css" href="asset/css/plugins/fullcalendar.min.css"/>
<link rel="stylesheet" href="asset/datepicker/datepicker3.css">
<link rel="stylesheet" type="text/css" href="asset/css/plugins/datatables.bootstrap.min.css"/>
<link href="asset/css/style.css" rel="stylesheet">
<link rel="stylesheet" href="asset/select2/select2.min.css">
<!-- end: Css -->
<script type="text/javascript" src="asset/js/jquery.min.js"></script>
<script type="text/javascript" src="ajax.js"></script>
<link rel="shortcut icon" href="asset/img/logomi.png">
</head>
<body>
<div id="content">
<div class="bs-example">
<input type="text" name="typeahead" class="typeahead tt-query" autocomplete="off" spellcheck="false" placeholder="Type your Query">
</div>
</div>
</div>
please help... thanks..
Please try by including the js and other bootstrap files first. And then try to execute the jquery and ajax code.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="typeahead.min.js"></script>
<script>
$(document).ready(function(){
$('input.typeahead').typeahead({
name: 'typeahead',
remote:'search.php?key=%QUERY',
limit : 10
});
});
</script>
Now it will works. Also make sure that all the js related files are included properly. While running the page in browser, type f12 and check the ajax call is generated or not.Hope it works.

php:two calendar is not showing

Two calendar is not showing in one php file. scenario is below
I have a php file name temp. Here i want to show two calendar(previous month and next month).
<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="left1"><?php include('calendar_previous.php');?></div>
<div id="right1"><?php include('calendar_next.php');?>hello</div>
</body>
</html>
My calendar_previous.php is
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="css/datetimepicker_css.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>BuildUp Real Estate</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="admin.css" />
<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />
<script type="text/javascript" src="css/jquery.1.4.2.js"></script>
<script type="text/javascript" src="css/jsDatePick_prev.jquery.min.1.3.js"></script>
<script type="text/javascript">
window.onload = function(){
g_globalObject = new JsDatePick({
useMode:1,
isStripped:true,
target:"inputField1"
});
g_globalObject.setOnSelectedDelegate(function(){
var obj = g_globalObject.getSelectedDay();
alert("a date was just selected and the date is : " + obj.day + "/" + obj.month + "/" + obj.year);
document.getElementById("div3_example_result").innerHTML = obj.day + "/" + obj.month + "/" + obj.year;
});
};
</script>
</head>
<body>
<div id="inputField1"></div>
</body>
</html>
My calendar_next.php is almost same to calendar_previous.php with two difference of javascript
<script type="text/javascript" src="css/jquery.1.4.4.js"></script>
<script type="text/javascript" src="css/jsDatePick_next.jquery.min.1.3.js"></script>
When i call calendar_previous.php and calendar_next.php separately it is showing previous and next month properly. But when i include this two php file in temp.php in different div only one calendar is showing. I want to show two calendar in temp.php in different div.
Any help is appreciate.
I guess its because now you are having two window.onload. So, that might be troubling. What you can try is place the contents of both window.onload to the second page and try.
2nd problem could be jquery conflict.
For that follow this
$s = jQuery.noConflict();
Now replace all of the $ with $s in one of your files.
That should resolve your problem. Tell me if it doesn't.

MOOTOOLS calling sexy.error() from PHP

I am very inexperienced with PHP and I've having trouble calling a mootools function.
Here's my code:
echo '<script language="JavaScript">';
echo "Sexy.error('Test!');";
echo '</script>';
When viewing source code looks like this:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Bath Solutions</title>
<link xmlns="" href="html_includes/css/main.css?version=10.03.05" rel="stylesheet" type="text/css" media="all" />
<link xmlns="" href="html_includes/mootools/Autocompleter.css?version=10.03.05" rel="stylesheet" type="text/css" media="screen" />
<link xmlns="" href="html_includes/css/print.css?version=10.03.05" rel="stylesheet" type="text/css" media="print" /><link xmlns="" href="html_includes/css/schedule.css?version=10.03.05" rel="stylesheet" type="text/css" media="all" />
<script language="javascript" type="text/javascript" src="html_includes/mootools.js?version=10.03.05"></script>
<script language="javascript" type="text/javascript" src="html_includes/main.js.php?version=10.03.05"></script>
<script language="javascript" type="text/javascript" src="html_includes/datepicker.js?version=10.03.05"></script>
<script language="javascript" type="text/javascript" src="html_includes/mootools/Observer.js?version=10.03.05"></script>
<script language="javascript" type="text/javascript" src="html_includes/mootools/Autocompleter.js?version=10.03.05"></script>
<script language="javascript" type="text/javascript" src="html_includes/mootools/Autocompleter.Request.js?version=10.03.05"></script>
<script type="text/javascript" src="html_includes/mootools/sexyalert/sexyalertbox.v1.2.moo.js?version=10.03.05"></script>
<link rel="stylesheet" type="text/css" media="all" href="html_includes/mootools/sexyalert/sexyalertbox.css?version=10.03.05"/>
<script type="text/javascript" src="html_includes/fckeditor/fckeditor.js?version=10.03.05"></script>
</head>
<body>
<script language="JavaScript">Sexy.error('Test!');</script>
...
When I try it with a simple alert('test') it works just fine.. I'm confused?!?
UPDATE: I tried a calling the Sexy.error() onClick in an anchor tag and it works fine:
click to test
wrap the call into a domready
<script type="text/javascript">
window.addEvent("domready", function() {
Sexy.error('test');
});
</script>
if the class depends on any part of the dom, like <div id='sexy'></div> being 'there', it won't work as is--at the time of running of the script block, the target div won't be available for DOM manipulations yet.
You haven't specified your version of mootools, but according to this there is not error method. Try changing your code to:
echo '<script language="JavaScript">';
echo "Sexy.alert('Test!');";
echo '</script>';
instead.
and remember to add this to your html too:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.1/mootools-yui-compressed.js"></script>
<script type="text/javascript" src="sexyalertbox.v1.2.moo.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="sexyalertbox.css"/>
You have to learn how to use FireBug - will help you greatly in such cases.

Categories