|
foreach ( $mts_options['mts_featured_post_cat'] as $cat_id ) {
The error message means that the value returned in $mts_options['mts_featured_post_cat'] is not valid for some reason. You need to find out what value(s) is being returned from that reference.
|
|
|
|
|
Member 14647122 wrote: Warning: Invalid argument supplied for foreach() in /home2/siilverp/public_html/wp-content/themes/mts_steadyincome/page-home.php on line 108
Did you alter the code in the code block you posted?
I checked the array and it contains the records being checked first. Not sure which is line 108 however.
["mts_featured_posts"]=> string(1) "1"
["mts_featured_post_cat"]=> string(1) "1"
I'm not a WordPress guy and haven't written a line of PHP in 4 years, but I suspect you altered the code to make it do something else and need to restore the page code from the original. Or the data in the array is corrupt or your missing something in the original setup of the pages.
WordPress was designed for non programmers to be able to setup a fast website blog. There is no need to edit code, except for the initial setup of passwords and crypt pass phrases. You just run the program and use the system to enter your blogs.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
i want to develop final project allocation and management system for computing college of my university and how can i avoid plagiarism of my project based on project documentation or project title
|
|
|
|
|
You can avoid plagiarism by submitting only your own original work, and not copying from other people. However this has nothing to do with software development.
|
|
|
|
|
So initially when I call my view it pulls the files from the database which users have uploaded and it allows users to delete those files if they don't need them anymore , this is done by when they click on the specific Actionlink, it calls a jquery function which calls my ajax which calls my Remove() Function in my controller , when the files are deleted I append the new list back to the customer.
My Issue: When the new list is appended back, the jquery function is no longer called and it goes directly to the method in my controller. I checked my html anchor-tag in my developer tools of both the appended files and the originally uploaded files and they are identical , I am not sure what is causing this issue, and help will be greatly appreciated.
Here is the anchor tags that work initially when the page is loaded:
<div class="portlet-body form " id="attachments">
@if (ViewBag.file != null)
{
foreach (var x in ViewBag.file)
{
if (string.IsNullOrWhiteSpace(x.FileName))
{
continue;
}
@Html.ActionLink(" ", "Remove", "Chargeback", new { name = (string)x.FileName, filePath = (string)x.FilePath }, new { @class = "fas fa-trash-alt", @id = "uploadsGif" })
@Html.ActionLink((string)x.FileName, "DownloadFile", "Chargeback", new { name = (string)x.FileName, id = "uploads" }, null)
DateTime.Now.ToString("MM/dd/yyyy");
}
}
</div>
Here is my jquery function which is appending my achor-tag/ActionLink:
$("#uploadsGif").click(function () {
debugger;
...
debugger;
$.ajax({
type: 'POST',
url: "/Chargeback/Remove",
dataType: 'json',
data: {
name: name,
filePath: filePath
},
success: function (data) {
debugger;
$("#lblresponce").append("File has been successfully removed");
setTimeout(function () {
$("#lblresponce").empty();
}, 5000)
debugger;
$("#attachments").empty();
$.each(data, function (i, item) {
$("#attachments").append('<a class="fas fa-trash-alt" href=/Chargeback/Remove?name=' + data[0].FileName + ';filePath=' + data[0].FilePath + 'id="uploadsGif"'+'>' + '</a>'); --> ISSUE $("#attachments").append('<a href=/Chargeback/DownloadFile/uploads?name=' + data[0].FileName +'>' + data[0].FileName + '</a>');
});
},
error: function (data) {
}
});
debugger;
return false;
})
|
|
|
|
|
|
Thank you so much, I originally doing it this way ("#uploadsGif").on("click",function(){
})
.
|
|
|
|
|
When appending elements dynamically you have to attach the event to a static parent element, and supply a filter which you wish to delegate events to, like this:
This was my solution:
$("#mainDiv").on('click', '.interested', function(){
alert("working");
});
|
|
|
|
|
how to create the login page using php and html code and how i get the information?
|
|
|
|
|
Google for "login php" and you will find many examples.
|
|
|
|
|
I have an ActionLink:
@Html.ActionLink(" ", "Remove", "Chargeback", new { name = (string)x.FileName, filePath = (string)x.FilePath}, new { @class = "fas fa-trash-alt" , @id = "uploadsGif" })
is there a way to grab the name and filepath with jquery?
|
|
|
|
|
Yes, look at the actual hmtl generated and you can find how to parse it with jquery.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Im kind of new to Jquery, here is the code genereted:
Are you able to provide how I would actually do that?
<a class="fas fa-trash-alt" href="/Chargeback/Remove?name=Working.xlsx&filePath=C%3A%5CCbUploads%5C7.xlsx" id="uploadsGif"> </a><a href="/Chargeback/DownloadFile/uploads?name=Working.xlsx">Working.xlsx</a> <br />
|
|
|
|
|
If you're using a modern browser - basically, anything except Internet Explorer - you can use the built-in URLSearchParams[^] class.
let link = document.getElementById("uploadsGif");
let query = link.href.substr(link.href.indexOf("?"));
let qs = new URLSearchParams(query);
let name = qs.get("name");
let filePath = qs.get("filePath"); If you need to support Internet Explorer, you could use a library like URI.js[^]. Or, you could use a simple function to extract the variable - for example: Get Query String Parameters with JavaScript[^]
function getUrlParameter(search, name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
...
var link = document.getElementById("uploadsGif");
var query = link.href.substr(link.href.indexOf("?"));
var name = getUrlParameter(query, "name");
var filePath = getUrlParameter(query, "filePath");
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you , you are a life saver.
|
|
|
|
|
I have both a standard ASP.Net Web PI running, as well as a SignalR API, running in IIS.
- For the web API, I have been making a call to the API's Test Controller's Test Method. If it succeeds, then I assume it's working, if not, then I assume the site isn't running.
- For the SignalR API, I call a method called 'Connect()' via the hub and wait for ConnectionStateChanged to indicated Connection State = Connected. Problem is, this response may never come.
So, what's the right way to test if both of these APIs are running?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Hi to all,
I am having live web application, which some times log out due to post back in firefox only.
At that time Session become null and Log Out.
In Other browsers working fine. I am using Firefox 69.0.2 (Latest) version.
Log Out happnes into Live Clients or in Production server only. In web developement working fine.
I am having Old Web Application around 12 years old web site (Product) and successfully using 150+ clients.
Some clients facing this issue. I have checked at my end. Issue still persist in some pages of web site.
Any one faced same issue?
Is there any thing that i can check that issue in otherway ?
Thank You
|
|
|
|
|
Siddharth Chudasama wrote: which some times log out due to post back What does that mean? How does a postback cause a session timeout?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Currently I want to grab the name of my uploaded file in Ajax and pass it to my APIController and pass it to my parameter.
1.Here is my controller :
public class ApiSampleUploadController : ApiController
{
[HttpPost]
public string Test(HttpPostedFileBase file )
{
return "Success";
}
}
2.Here is my view:
@using (Html.BeginForm("Submit"))
{
<div>
<input type="file" name="file" id="uploadFile" />
</div>
}
3.Here is my ajax
$('#uploadFile').on("change", function () {
var formdata = new FormData($('form').get(0));
CallUpload(formdata);
});
function CallUpload(file) {
console.log(file);
$.ajax({
url: '/api/ApiSampleUpload/Test',
type: 'POST',
data: 'file=' + file ,
cache: false,
processData: false,
contentType: 'application/json',
success: function () {
alert('Success');
},
error: function () {
alert('Error occured');
}
});
}
|
|
|
|
|
Two problems:
1) You're missing the enctype on the form:
@using (Html.BeginForm("Test", "ApiSampleUpload", FormMethod.Post, new { enctype = "multipart/form-data" }))
2) You're converting the FormData to a string, so you're submitted data will be file=[object FormData] .
You need to pass the FormData directly to the data parameter instead.
You're also specifying the wrong content type for the upload.
function CallUpload(file) {
console.log(file);
$.ajax({
url: '/api/ApiSampleUpload/Test',
type: 'POST',
data: file,
cache: false,
processData: false,
contentType: false,
success: function () {
alert('Success');
},
error: function () {
alert('Error occured');
}
});
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
1.So should data be like : data: 'file=' + new FormData($('form').get(0))
2.When setting contentType:false I get a 415 (Unsupported Media Type)
|
|
|
|
|
KGr28 wrote: 1.So should data be like : data: 'file=' + new FormData($('form').get(0))
No, it needs to be the FormData object, not a string representation of it:
data: new FormData($('form').get(0)) But in the code you posted, you've already created that FormData object and passed it in as a parameter, so you should just re-use that:
data: file
KGr28 wrote: 2.When setting contentType:false I get a 415 (Unsupported Media Type)
Try explicitly setting it to multipart/form-data then:
contentType: 'multipart/form-data',
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
still get the same error.
|
|
|
|
|
I'm trying to test a C# Web API. I go to a browser and enter "localhost:65078/api/test/test", it fails with "Response status code does not indicate success: 401 (Unauthorized)."
If I use "[http://192.168.51.66:65078/api/test/test](http://192.168.51.66:65078/api/test/test)" then it works. Here's my test code:
private static async Task TestWebAPI(string url)
{
using (var client = new HttpClient())
{
using (var httpResponse = await client.GetAsync(url))
{
try
{
httpResponse.EnsureSuccessStatusCode();
string responsContent = await httpResponse.Content.ReadAsStringAsync();
}
catch (Exception e)
{
_logger.Log(LogLevel.Error, e);
}
}
}
}
There are a lot of responses on Google about this message. Anyone have any insight into what might be wrong?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
httpResponse.EnsureSuccessStatusCode(); This line will always raise an exception is the response is not a success status code—which falls in the range of 200-299 of HTTP status code. Now for your second case, why 401, that means that the server is expecting to read an authentication credential (username/password, bearer token, etc.) which was not passed with the request.
One more thing that I want to highlight here is that, localhost is not 192.168.51.66 . You might be confusing that every request will be forwarded to localhost before being terminated. If a server is listening on, 192.168.51.66, then it will only be listening to requests on that particular IP address. Same goes for port, and protocol (HTTP, FTP, etc.) and I believe that is why you are getting 401.
Solution is either keep using the IP address that you are being provided with, or map the service to listen to HTTP requests on localhost (127.0.0.1) to solve this problem.
HttpResponseMessage.IsSuccessStatusCode Property (System.Net.Http) | Microsoft Docs
HttpResponseMessage.EnsureSuccessStatusCode Method (System.Net.Http) | Microsoft Docs
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|